/* =========================================================
   Le Petit Bac · cahier d'écolier
   ========================================================= */

:root {
  --paper: #f5efdf;
  --paper-dark: #ebe2c8;
  --ink: #1a3a6b;
  --ink-soft: #355687;
  --red: #c0392b;
  --highlight: #f7d54a;
  --green: #2d7a4f;
  --line: rgba(26, 58, 107, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Fraunces', Georgia, serif;
  min-height: 100%;
}

button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

.font-display { font-family: 'Fraunces', serif; }
.font-hand { font-family: 'Caveat', cursive; }
.font-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ---- Layout ---- */
.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}
.app-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    transparent, transparent 31px,
    var(--line) 31px, var(--line) 32px
  );
  opacity: 0.6;
}
.app-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(247, 213, 74, 0.15), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(192, 57, 43, 0.08), transparent 40%);
}
.container {
  position: relative;
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}
@media (min-width: 768px) {
  .container { padding: 3rem 1.5rem; }
}

/* ---- Header ---- */
header.main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--ink);
}
.title-kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}
.title {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  line-height: 1;
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.2rem, 6vw, 4rem);
}
.code-badge {
  text-align: right;
}
.code-badge .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.code-badge .value {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: 0.2em;
  color: var(--red);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  transition: transform 0.1s;
  text-decoration: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--red);
  color: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  font-weight: 800;
  padding: 1rem 2rem;
  font-size: 1.125rem;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.btn-stop {
  background: var(--ink);
  color: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--red);
  font-weight: 800;
  padding: 1rem 2rem;
  font-size: 1.25rem;
}
.btn-link {
  background: none;
  border: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red);
  text-decoration: underline;
  padding: 0.5rem;
}

/* ---- Form inputs ---- */
.ink-input {
  font-family: 'Caveat', cursive;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--line);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
  font-size: 1.5rem;
  padding: 0.25rem 0;
  width: 100%;
}
.ink-input:focus { border-bottom-color: var(--ink); }
.ink-input::placeholder { color: rgba(26, 58, 107, 0.3); }

/* ---- Sections ---- */
section { margin-bottom: 2rem; }
.section-title {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0 0 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  color: var(--ink);
}
.section-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--red);
}
.section-hint {
  font-family: 'Caveat', cursive;
  font-size: 1.2rem;
  color: var(--ink-soft);
  font-weight: normal;
}

/* ---- Category buttons ---- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 768px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
}
.cat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: 'Fraunces', serif;
  font-weight: 600;
  text-align: left;
  transition: all 0.15s;
}
.cat-btn.active {
  background: var(--ink);
  color: var(--paper);
}
.cat-btn:disabled { cursor: default; }
.cat-emoji { font-size: 1.25rem; }

/* ---- Duration buttons ---- */
.dur-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.dur-btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.125rem;
}
.dur-btn.active {
  background: var(--highlight);
  transform: rotate(-1deg) scale(1.05);
}

/* ---- Players ---- */
.player-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--ink);
}
.player-card.me { background: var(--highlight); }
.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.player-bg-0 { background: #1a3a6b; }
.player-bg-1 { background: #c0392b; }
.player-bg-2 { background: #2d7a4f; }
.player-bg-3 { background: #b97e00; }
.player-bg-4 { background: #6f42c1; }
.player-bg-5 { background: #e76f51; }
.player-name {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  background: var(--ink);
  color: var(--paper);
  padding: 2px 8px;
  margin-left: auto;
}
.you-tag {
  font-family: 'Caveat', cursive;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-left: auto;
}

/* ---- Share box ---- */
.share-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--paper-dark);
  border: 2px solid var(--ink);
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.share-label {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.share-code {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 3.75rem;
  letter-spacing: 0.2em;
  color: var(--red);
  line-height: 1;
}

/* ---- Game banner ---- */
.game-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}
.banner-letter {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 4.5rem;
  color: var(--ink);
  text-shadow: 5px 5px 0 var(--highlight);
  line-height: 1;
}
.banner-timer {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 3rem;
  color: var(--ink);
}
.banner-timer.warn { color: var(--red); animation: pulse-warn 0.7s infinite; }

/* ---- Play row ---- */
.play-rows { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 2rem; }
.play-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.play-cat {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 11rem;
  flex-shrink: 0;
}
.play-cat-emoji { font-size: 1.5rem; }
.play-cat-label {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.05rem;
}
.play-input-wrap {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 200px;
}
.play-letter {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 1.875rem;
  color: var(--red);
}
.play-input {
  flex: 1;
  font-size: 1.875rem;
  padding-bottom: 0.25rem;
}

/* ---- Drawing animation ---- */
.drawing-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 0;
}
.drawing-letter {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: min(50vw, 22rem);
  color: var(--ink);
  line-height: 1;
  text-shadow: 8px 8px 0 var(--highlight);
}

/* ---- Results ---- */
.result-info {
  background: var(--paper-dark);
  border-left: 4px solid var(--ink);
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: var(--ink);
}
.score-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.score-row .name {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.125rem;
}
.score-row .points {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--red);
}
.score-row .total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--ink-soft);
}
.score-row .filler {
  flex: 1;
  height: 1px;
  background: var(--line);
}
.cat-result-block {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--line);
  padding: 1rem;
  margin-bottom: 1rem;
}
.cat-result-title {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.125rem;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cat-answer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
}
.cat-answer-row .pname {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  width: 6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-answer-row .answer {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-answer-row .answer.invalid { text-decoration: line-through; color: var(--ink-soft); }
.cat-answer-row .pts {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1rem;
}
.cat-answer-row .pts.gain { color: var(--green); }
.cat-answer-row .pts.zero { color: var(--ink-soft); }
.shared-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.check, .cross {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  color: white;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
}
.check { background: var(--green); }
.cross { background: var(--red); }
.check:hover, .cross:hover { transform: scale(1.15); }
.check:disabled, .cross:disabled { opacity: 0.3; cursor: default; }

/* ---- Stop banner ---- */
.stop-banner {
  background: var(--red);
  color: var(--paper);
  padding: 0.75rem;
  text-align: center;
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  animation: shake 0.5s infinite;
}

/* ---- Footer ---- */
footer.main {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---- Misc ---- */
.error-msg {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: var(--red);
  margin-top: 1rem;
}
.intro-text {
  font-size: 1.125rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  color: var(--ink-soft);
}
.intro-text .highlight {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  background: var(--highlight);
  padding: 0 6px;
  color: var(--ink);
}
.howto-list {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: var(--ink);
  list-style: none;
  padding: 0;
  margin: 0;
}
.howto-list li { padding: 0.15rem 0; }

.create-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) {
  .create-grid { grid-template-columns: 1fr 1fr; }
}
.join-row { display: flex; gap: 0.5rem; }
.join-row .ink-input {
  letter-spacing: 0.2em;
  font-family: 'Fraunces', serif;
  font-weight: 700;
}
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}
.submitted-msg {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  color: var(--green);
}
.submit-counter {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.waiting-host {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  animation: pulse-warn 0.7s infinite;
  color: var(--ink);
}
.score-divider {
  border-top: 1px dashed var(--line);
  padding-top: 1.5rem;
  margin-top: 3rem;
}
.score-divider h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}

/* ---- Animations ---- */
@keyframes pop {
  0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(-3deg); opacity: 1; }
}
.pop { animation: pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

@keyframes pulse-warn {
  0%, 100% { color: var(--ink); }
  50% { color: var(--red); }
}
.pulse-warn { animation: pulse-warn 0.7s infinite; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
