@import url('https://fonts.googleapis.com/css2?family=Kreon:wght@400;500;600;700&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface2: #f0eff0;
  --surface3: #e4e3e8;
  --accent: #c87a1a;
  --accent2: #5040c8;
  --green: #1e7a4e;
  --red: #c0303e;
  --text: #1a1825;
  --text2: #4a4860;
  --text3: #8a88a0;
  --border: rgba(0,0,0,0.10);
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* NAV */
.nav {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.nav-btn {
  flex: 1;
  padding: 8px 4px;
  font-family: 'Kreon', serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}
.nav-btn.active {
  background: var(--surface2);
  color: var(--text);
}
.nav-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* SCREENS */
.screen { display: none; flex: 1; padding: 20px 16px 40px; overflow-y: auto; }
.screen.active { display: block; }

/* TYPOGRAPHY */
h1 {
  font-family: 'Kreon', serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
h2 {
  font-family: 'Kreon', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}
h3 {
  font-family: 'Kreon', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* INPUTS */
input[type=text], input[type=number] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input[type=text]:focus, input[type=number]:focus {
  border-color: var(--accent2);
}
input[type=number] { text-align: center; }

/* BUTTONS */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  font-family: 'Kreon', serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--text);
  color: var(--bg);
}
.btn-primary:hover { background: var(--text2); }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-end {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(192,48,62,0.3);
}
.btn-end:hover { background: #fad4d8; }
.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: 'Kreon', serif;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent2); color: var(--text); }
.btn-sm.danger:hover { border-color: var(--red); color: var(--red); }

/* BADGE */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Kreon', serif;
}
.badge-green { background: #d4f0e2; color: var(--green); }
.badge-red { background: #fad4d8; color: var(--red); }
.badge-amber { background: #fce8cc; color: var(--accent); }
.badge-purple { background: #dddafc; color: var(--accent2); }
.badge-neutral { background: var(--surface2); color: var(--text2); }

/* AVATAR */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Kreon', serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent2);
  flex-shrink: 0;
}

/* PLAYER ROW */
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.player-row:last-child { border-bottom: none; }

/* ANNOUNCE TABLE */
.announce-table { width: 100%; border-collapse: collapse; }
.announce-table th {
  font-family: 'Kreon', serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0 4px 8px;
  text-align: center;
}
.announce-table th:first-child { text-align: left; }
.announce-table td {
  padding: 5px 4px;
  vertical-align: middle;
}
.announce-table td:first-child { font-size: 14px; font-weight: 500; }
.announce-table input[type=number] {
  padding: 8px 4px;
  font-size: 16px;
  font-weight: 600;
}

/* SCORE TABLE */
.score-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.score-table { width: 100%; border-collapse: collapse; min-width: 280px; }
.score-table th {
  font-family: 'Kreon', serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
}
.score-table th:first-child { text-align: left; }
.score-table td {
  padding: 8px;
  text-align: center;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.score-table td:first-child {
  text-align: left;
  font-weight: 500;
  font-size: 14px;
}
.score-table tr.leader td:first-child { color: var(--accent); }

/* METRIC */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.metric-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; font-family: 'Kreon', serif; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-value { font-family: 'Kreon', serif; font-size: 24px; font-weight: 800; color: var(--text); }
.metric-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ROUND HEADER */
.round-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.round-title {
  font-family: 'Kreon', serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.round-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* PROGRESS BAR */
.progress-bar {
  height: 3px;
  background: var(--surface2);
  border-radius: 99px;
  margin-bottom: 16px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* FORBIDDEN WARNING */
.warn-box {
  background: #fad4d8;
  border: 1px solid rgba(192,48,62,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--red);
  margin-top: 10px;
  display: none;
}
.warn-box.visible { display: block; }

/* INFO ROW */
.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 12px;
}

/* ROUNDS SEQUENCE */
.seq-wrap { display: flex; flex-wrap: wrap; gap: 5px; }
.seq-pill {
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Kreon', serif;
  background: var(--surface2);
  color: var(--text3);
  border: 1px solid var(--border);
}
.seq-pill.current {
  background: var(--accent);
  color: #0f0e17;
  border-color: transparent;
}
.seq-pill.done {
  background: rgba(76,175,130,0.1);
  color: var(--green);
  border-color: rgba(76,175,130,0.2);
}

/* SETTINGS */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 14px; }
.setting-desc { font-size: 12px; color: var(--text3); margin-top: 2px; }
.setting-row input[type=number] { width: 70px; }

/* RULES */
.rule-block {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.rule-block:last-child { border-bottom: none; }
.rule-block p { font-size: 14px; color: var(--text2); line-height: 1.65; margin-top: 6px; }

/* CONFETTI AREA */
.winner-banner {
  text-align: center;
  padding: 24px 0;
}
.winner-banner .crown { font-size: 48px; }
.winner-name {
  font-family: 'Kreon', serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  margin: 8px 0 4px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface3);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-family: 'Kreon', serif;
  font-weight: 600;
  border: 1px solid var(--border);
  transition: transform 0.3s ease;
  z-index: 999;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* SUIT INDICATOR */
.suit { font-size: 20px; cursor: pointer; padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface2); transition: all 0.15s; }
.suit.selected-red { background: rgba(224,92,106,0.2); border-color: var(--red); }
.suit.selected-black { background: rgba(160,159,192,0.15); border-color: var(--text2); }
.suits-row { display: flex; gap: 8px; margin-bottom: 12px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }

/* COMPTE */
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: 'Kreon', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: all 0.15s;
}
.google-btn:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

.historique-empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--text3);
  font-size: 13px;
}

footer {
  text-align: center;
  padding: 16px;
  font-size: 0.72rem;
  color: var(--text3);
}
.powered-by { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text3); transition: opacity 0.15s; }
.powered-by:hover { opacity: 0.6; }
.powered-by img { height: 15px; width: auto; display: block; opacity: 0.65; }
