:root {
  --ink: #e8dcc3;
  --muted: #9f957e;
  --paper: #d7c49f;
  --paper-dark: #8d7652;
  --wood: #32271b;
  --wood-deep: #18130f;
  --panel: rgba(24, 20, 15, 0.93);
  --panel-soft: rgba(48, 39, 28, 0.82);
  --line: rgba(225, 202, 158, 0.24);
  --amber: #d99c45;
  --red: #a54232;
  --green: #6f8c61;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  --radius: 5px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #0e0c09; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(9, 8, 6, .82), rgba(9, 8, 6, .88)),
    url("assets/bureau.webp") center / cover fixed;
  font-family: Georgia, "Times New Roman", serif;
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  opacity: .11; mix-blend-mode: screen;
  background-image:
    repeating-radial-gradient(circle at 12% 23%, transparent 0 1px, rgba(255,255,255,.14) 1px 2px, transparent 2px 5px),
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(255,255,255,.04) 3px 4px);
}

.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px clamp(16px, 3vw, 38px);
  background: rgba(18, 15, 11, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; background: none; border: 0; cursor: pointer; text-align: left; padding: 0; }
.brand-mark {
  display: grid; place-items: center; width: 42px; aspect-ratio: 1;
  border: 1px solid var(--paper-dark); border-radius: 50%;
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em;
}
.brand strong, .brand small { display: block; }
.brand strong { font: 700 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.brand small { color: var(--muted); font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; margin-top: 2px; }
.mission-status { display: flex; align-items: center; gap: 10px; }
.timer-block { min-width: 112px; text-align: right; padding-right: 14px; border-right: 1px solid var(--line); }
.timer-block small, .timer-block strong { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.timer-block small { color: var(--muted); font-size: 9px; letter-spacing: .16em; }
.timer-block strong { color: var(--amber); font-size: 24px; letter-spacing: .06em; }
.timer-block.danger strong { color: #ef7960; animation: pulse 1s infinite; }
.icon-button, .back-button, .secondary-button {
  border: 1px solid var(--line); background: rgba(255,255,255,.03); cursor: pointer; border-radius: 3px;
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .11em;
  padding: 11px 13px; transition: .2s ease;
}
.icon-button:hover, .back-button:hover, .secondary-button:hover { border-color: var(--paper-dark); background: rgba(217,156,69,.08); }

main { min-height: 0; }
.screen { display: none; min-height: calc(100vh - 79px); padding: clamp(24px, 5vw, 64px); }
.screen.active { display: block; animation: screenIn .38s ease both; }
.intro-screen, .success-screen { display: none; place-items: center; }
.intro-screen.active, .success-screen.active { display: grid; }
.hero-panel {
  width: min(920px, 100%); padding: clamp(26px, 5vw, 58px);
  background: linear-gradient(135deg, rgba(35,28,20,.97), rgba(17,14,10,.96));
  border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero-panel::after { content: "09"; position: absolute; right: -15px; bottom: -66px; color: rgba(217,156,69,.04); font-size: 300px; font-weight: 700; line-height: 1; }
.classification { display: inline-block; padding: 7px 10px; border: 1px solid var(--red); color: #d57b68; font: 700 10px/1 ui-monospace, monospace; letter-spacing: .18em; transform: rotate(-1deg); }
.eyebrow { color: var(--amber); font: 700 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .22em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 760px; margin: 24px 0 16px; font-size: clamp(40px, 7vw, 76px); line-height: .98; font-weight: 500; letter-spacing: -.045em; }
h2 { font-size: clamp(28px, 4vw, 48px); font-weight: 500; letter-spacing: -.025em; }
h3 { font-size: 21px; font-weight: 500; }
.lead { max-width: 660px; color: #c9bfa9; font-size: clamp(17px, 2.2vw, 22px); line-height: 1.55; }
.rules-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 34px 0; background: var(--line); border: 1px solid var(--line); }
.rules-grid article { padding: 20px; background: #19150f; }
.rules-grid strong, .rules-grid span { display: block; }
.rules-grid strong { color: var(--amber); font: 700 10px/1 ui-monospace, monospace; letter-spacing: .18em; margin-bottom: 8px; }
.rules-grid span { color: var(--muted); line-height: 1.45; }
.primary-button {
  position: relative; z-index: 1; border: 1px solid #d8a75c; background: linear-gradient(#b97831, #8e5624); color: #fff3dd;
  padding: 16px 21px; border-radius: 3px; cursor: pointer;
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em;
  box-shadow: inset 0 1px rgba(255,255,255,.18), 0 8px 30px rgba(0,0,0,.24); transition: .2s ease;
}
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.primary-button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.primary-button.compact { padding: 13px 16px; }

.terminal-card { width: min(820px, 100%); margin: 4vh auto; background: rgba(15, 18, 13, .97); border: 1px solid #46513d; box-shadow: var(--shadow), inset 0 0 70px rgba(83,112,65,.06); }
.terminal-card.narrow { width: min(690px, 100%); }
.terminal-header { display: flex; gap: 7px; align-items: center; padding: 12px 16px; border-bottom: 1px solid #35412f; background: #11140f; }
.terminal-header span { width: 8px; height: 8px; border-radius: 50%; background: #5c604f; }
.terminal-header b { margin-left: auto; color: #899878; font: 700 10px/1 ui-monospace, monospace; letter-spacing: .15em; }
.typewriter-window { padding: clamp(26px, 5vw, 52px); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #a5bd8e; line-height: 1.65; }
.terminal-note { color: #67755d; }
.typewriter-window label, .field-label { display: block; color: var(--muted); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .18em; margin: 26px 0 8px; }
.terminal-input-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #617557; padding: 8px 0; margin-bottom: 24px; }
.terminal-input-row input { flex: 1; min-width: 0; border: 0; background: transparent; color: #d1e5c0; text-transform: uppercase; font: 19px/1.3 ui-monospace, monospace; outline: 0; }
.terminal-input-row input::placeholder { color: #4c5a44; }
.feedback { min-height: 1.4em; margin: 16px 0 0; color: var(--muted); font: 12px/1.5 ui-monospace, monospace; letter-spacing: .04em; }
.feedback.error { color: #dc7c67; }
.feedback.success { color: #9fc48b; }

#screen-dashboard { max-width: 1280px; margin: auto; padding-bottom: 120px; }
.dashboard-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 30px; }
.dashboard-heading h2 { margin-bottom: 0; }
.progress-ring { width: 78px; height: 78px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; grid-template-columns: auto auto; background: rgba(20,16,12,.8); }
.progress-ring span { font: 700 28px/1 ui-monospace, monospace; color: var(--amber); }
.progress-ring small { color: var(--muted); }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.module-card {
  min-height: 190px; position: relative; overflow: hidden; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: linear-gradient(135deg, rgba(47,37,26,.94), rgba(19,16,12,.96));
  padding: 27px; box-shadow: 0 12px 45px rgba(0,0,0,.21); transition: .22s ease;
}
.module-card:hover { transform: translateY(-3px); border-color: rgba(217,156,69,.62); }
.module-card::after { content: ""; position: absolute; inset: auto -20% -60% 35%; height: 170%; border: 1px solid rgba(217,156,69,.08); border-radius: 50%; transform: rotate(-18deg); }
.module-number, .module-state { font: 700 9px/1 ui-monospace, monospace; letter-spacing: .16em; }
.module-number { color: var(--paper-dark); }
.module-icon { position: absolute; top: 26px; right: 28px; color: rgba(217,156,69,.65); font-size: 27px; }
.module-card strong, .module-card small { display: block; position: relative; z-index: 1; }
.module-card strong { margin-top: 42px; font-size: 25px; font-weight: 500; }
.module-card small { color: var(--muted); margin-top: 5px; }
.module-state { position: absolute; z-index: 2; right: 26px; bottom: 24px; color: #8d9b78; }
.module-card.complete { border-color: rgba(111,140,97,.7); background: linear-gradient(135deg, rgba(40,52,34,.92), rgba(17,22,15,.96)); }
.module-card.complete .module-state { color: #a6c391; }
.module-card.locked { opacity: .48; cursor: not-allowed; filter: grayscale(.5); }
.module-card.final-card { grid-column: 1 / -1; min-height: 145px; }
.module-card.final-card strong { margin-top: 28px; }

.module-screen { max-width: 1380px; margin: auto; padding-bottom: 130px; }
.module-titlebar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; margin-bottom: 28px; }
.module-titlebar h2, .module-titlebar p { margin-bottom: 0; }
.module-badge { padding: 8px 10px; border: 1px solid var(--line); color: var(--muted); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .16em; }
.module-badge.danger { color: #d17966; border-color: rgba(165,66,50,.65); }
.puzzle-layout { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(420px, 1.6fr); gap: 18px; }
.dossier-panel, .puzzle-panel, .radio-console, .schedule-console, .final-console {
  border: 1px solid var(--line); background: var(--panel); box-shadow: 0 18px 50px rgba(0,0,0,.22); padding: clamp(22px, 3vw, 36px);
}
.dossier-panel { background: linear-gradient(150deg, rgba(55,44,31,.95), rgba(25,20,15,.96)); }
.dossier-panel p { color: #bdb29c; line-height: 1.65; }
.instruction { padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; }

.token-bank { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.object-token {
  border: 1px solid var(--line); background: rgba(255,255,255,.035); padding: 12px 8px; cursor: grab; text-align: center; border-radius: 3px;
  font: 700 10px/1.25 ui-monospace, monospace; letter-spacing: .06em; transition: .15s ease;
}
.object-token:hover, .object-token.selected { border-color: var(--amber); background: rgba(217,156,69,.11); }
.object-token.placed { opacity: .28; cursor: default; }
.object-token span { display: block; font-size: 24px; margin-bottom: 8px; color: var(--paper); }
.desk-view-label { text-align: center; color: var(--muted); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .18em; margin-bottom: 15px; }
.desk-grid {
  min-height: 470px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 10px; padding: 18px;
  border: 7px solid #4a321e; outline: 1px solid #7c5a32; background:
    linear-gradient(rgba(79,62,43,.18) 1px, transparent 1px), linear-gradient(90deg, rgba(79,62,43,.18) 1px, transparent 1px),
    linear-gradient(145deg, rgba(151,132,96,.12), rgba(14,14,12,.66)); background-size: 42px 42px, 42px 42px, auto;
  margin-bottom: 20px; position: relative;
}
.desk-grid::before { content: "FAUTEUIL"; position: absolute; left: 50%; bottom: -31px; transform: translateX(-50%); color: var(--paper-dark); font: 700 8px/1 monospace; letter-spacing: .16em; }
.desk-slot { min-height: 110px; display: grid; place-items: center; border: 1px dashed rgba(215,196,159,.18); background: rgba(255,255,255,.018); cursor: pointer; transition: .15s ease; }
.desk-slot:hover, .desk-slot.dragover { border-color: var(--amber); background: rgba(217,156,69,.06); }
.desk-slot.filled { border-style: solid; }
.slot-token { text-align: center; font: 700 10px/1.3 ui-monospace, monospace; letter-spacing: .05em; }
.slot-token span { display: block; font-size: 28px; color: var(--paper); margin-bottom: 8px; }

.honors-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.honor-choice {
  min-height: 110px; display: grid; place-items: center; gap: 5px; border: 1px solid var(--line); background: rgba(255,255,255,.025); cursor: pointer; padding: 12px; text-align: center;
}
.honor-choice:hover, .honor-choice.used { border-color: var(--amber); }
.honor-choice.used { opacity: .32; cursor: default; }
.medal-symbol { width: 48px; height: 48px; border-radius: 50%; border: 2px solid #b99d5d; display: grid; place-items: center; color: #cbb578; box-shadow: inset 0 0 0 4px rgba(185,157,93,.12); font-weight: 700; }
.ribbon { width: 24px; height: 34px; margin: 0 auto -8px; border-radius: 2px 2px 8px 8px; }
.ribbon.striped { background: repeating-linear-gradient(90deg, #59616c 0 5px, #a44e43 5px 10px); }
.ribbon.green { background: linear-gradient(90deg, #5a7f55 0 38%, #9c4a40 38% 58%, #5a7f55 58%); }
.honor-choice small { color: var(--muted); font: 9px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
.honors-panel { display: grid; align-content: center; min-height: 480px; }
.sequence-label { color: var(--muted); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .18em; }
.honors-sequence, .color-sequence { min-height: 135px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0 28px; }
.sequence-slot { border: 1px dashed var(--line); display: grid; place-items: center; color: var(--paper-dark); font: 700 30px/1 monospace; min-height: 110px; }
.sequence-slot.filled { border-style: solid; background: rgba(217,156,69,.05); }
.button-row { display: flex; gap: 10px; justify-content: flex-end; }

.paper-input, .schedule-console select, .final-controls input, .final-controls select {
  width: 100%; border: 1px solid var(--line); background: #d4c4a4; color: #2b241b; border-radius: 2px; padding: 13px 14px;
  font: 700 14px/1.2 ui-monospace, monospace; text-transform: uppercase;
}
.map-console { min-height: 520px; }
.map-grid-art {
  height: 245px; position: relative; overflow: hidden; margin-bottom: 24px; border: 1px solid rgba(108,89,62,.8);
  background: #b8a985; color: #453a28;
  background-image: linear-gradient(rgba(72,60,42,.17) 1px, transparent 1px), linear-gradient(90deg, rgba(72,60,42,.17) 1px, transparent 1px);
  background-size: 28px 28px;
}
.map-grid-art::before { content: "CARTE PARTIELLEMENT CORROMPUE"; position: absolute; top: 12px; left: 14px; font: 700 8px/1 monospace; letter-spacing: .14em; opacity: .65; }
.map-grid-art i { position: absolute; width: 8px; height: 8px; border: 2px solid #2d281f; border-radius: 50%; }
.map-grid-art i:nth-of-type(1) { left: 52%; top: 15%; } .map-grid-art i:nth-of-type(2) { left: 36%; top: 35%; } .map-grid-art i:nth-of-type(3) { left: 63%; top: 54%; } .map-grid-art i:nth-of-type(4) { left: 45%; top: 72%; } .map-grid-art i:nth-of-type(5) { left: 58%; top: 86%; }
.route { position: absolute; height: 2px; transform-origin: 0 0; opacity: .22; }
.route-a { width: 125px; left: 52%; top: 17%; background: #9d4135; transform: rotate(145deg); }
.route-b { width: 155px; left: 37%; top: 37%; background: #1e1e1b; transform: rotate(31deg); }
.route-c { width: 130px; left: 64%; top: 56%; background: #9d4135; transform: rotate(147deg); }
.route-d { width: 95px; left: 46%; top: 74%; background: #1e1e1b; transform: rotate(45deg); }
.color-chip { min-height: 90px; border: 1px solid var(--line); display: grid; place-items: center; font: 700 10px/1 ui-monospace, monospace; letter-spacing: .1em; }
.color-chip.red { background: rgba(165,66,50,.58); }
.color-chip.black { background: #0d0d0c; }
.color-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.color-key { border: 1px solid var(--line); padding: 12px 18px; cursor: pointer; font: 700 10px/1 monospace; letter-spacing: .12em; }
.red-key { background: #74382f; } .black-key { background: #0c0c0b; }

.comms-grid { display: grid; grid-template-columns: minmax(400px, 1.25fr) minmax(300px, .75fr); gap: 18px; }
.radio-console { background: linear-gradient(145deg, rgba(63,44,27,.97), rgba(22,18,13,.98)); border: 8px solid #4a321e; outline: 1px solid #8b673d; }
.radio-top { display: flex; justify-content: space-between; color: var(--paper-dark); font: 700 9px/1 monospace; letter-spacing: .12em; margin-bottom: 16px; }
.radio-window { padding: 18px; background: #171b18; border: 2px solid #88704d; box-shadow: inset 0 0 35px rgba(102,126,77,.12); }
.station-scale { position: relative; height: 190px; display: flex; justify-content: space-between; align-items: end; gap: 4px; padding: 0 14px 28px; border-top: 1px solid #65715d; border-bottom: 1px solid #65715d; }
.station-scale::before, .station-scale::after { content: ""; position: absolute; left: 0; right: 0; border-top: 1px solid rgba(101,113,93,.38); }
.station-scale::before { top: 32%; } .station-scale::after { top: 64%; }
.station-scale span { writing-mode: vertical-rl; transform: rotate(180deg); color: #8ba07e; font: 10px/1 monospace; letter-spacing: .08em; }
.radio-needle { position: absolute; top: -10px; bottom: -10px; width: 2px; left: 15%; background: #d4b069; box-shadow: 0 0 12px #d4b069; transition: left .12s linear; }
.radio-slider { width: 100%; accent-color: var(--amber); margin: 23px 0 16px; }
.schedule-console p { color: var(--muted); line-height: 1.55; }
.clock-setter, .inline-clock { display: flex; align-items: end; gap: 10px; margin: 18px 0 26px; }
.clock-setter div { flex: 1; }
.clock-setter label { display: block; color: var(--muted); font: 700 9px/1 monospace; letter-spacing: .15em; margin-bottom: 7px; }
.clock-setter input, .inline-clock input { width: 100%; min-width: 0; background: #11100d; color: var(--amber); border: 1px solid var(--line); padding: 15px; text-align: center; font: 700 26px/1 monospace; }
.clock-setter > span, .inline-clock > span { color: var(--amber); font: 700 27px/1 monospace; padding-bottom: 13px; }

.final-console { max-width: 1000px; margin: auto; background: linear-gradient(145deg, rgba(32,37,27,.98), rgba(13,15,12,.98)); border-color: #46513d; }
.final-status { display: flex; gap: 10px; align-items: center; color: #849679; font: 700 10px/1 monospace; letter-spacing: .14em; padding-bottom: 22px; border-bottom: 1px solid #394431; }
.final-status span { width: 10px; height: 10px; border-radius: 50%; background: #704238; box-shadow: 0 0 12px rgba(165,66,50,.6); }
.final-status.ready span { background: #789764; box-shadow: 0 0 12px rgba(111,140,97,.8); }
.final-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 30px 0; }
.final-controls label { color: #79866e; font: 700 9px/1 monospace; letter-spacing: .14em; }
.final-controls input, .final-controls select { margin-top: 8px; background: #161a14; color: #aec09c; border-color: #3f4b37; }
.wide-control { grid-column: 1 / -1; }
.inline-clock { margin: 8px 0 0; align-items: center; }
.inline-clock input { padding: 11px; font-size: 16px; }
.inline-clock > span { padding: 0; }
.lever-button { display: grid; justify-items: center; gap: 12px; margin: 20px auto 4px; border: 0; background: transparent; cursor: pointer; color: #b9c9aa; font: 700 10px/1 monospace; letter-spacing: .14em; }
.lever-button span { display: block; width: 34px; height: 115px; border-radius: 22px; background: linear-gradient(90deg, #4d5047, #a6a796 42%, #41443c); border: 3px solid #242720; box-shadow: 0 9px 0 #12140f, 0 12px 20px rgba(0,0,0,.4); transform-origin: bottom; transition: .28s ease; }
.lever-button:hover span { transform: rotate(7deg); }
.lever-button.pulled span { transform: rotate(35deg); }

.inventory-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; padding: 12px clamp(16px, 3vw, 38px); background: rgba(15,12,9,.96); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
.inventory-bar.hidden { display: none; }
.inventory-bar small { color: var(--muted); font: 700 8px/1 monospace; letter-spacing: .16em; }
.inventory-items { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.inventory-item { padding: 5px 8px; border: 1px solid rgba(111,140,97,.45); color: #9fb88c; font: 700 9px/1 monospace; letter-spacing: .08em; }
.progress-line { position: absolute; top: 0; left: 0; right: 0; height: 2px; background: rgba(255,255,255,.04); }
.progress-line span { display: block; width: 0; height: 100%; background: var(--amber); transition: width .35s ease; }

.modal-dialog { width: min(520px, calc(100% - 28px)); color: var(--ink); background: #1b1711; border: 1px solid var(--paper-dark); box-shadow: 0 30px 100px rgba(0,0,0,.65); padding: 34px; }
.modal-dialog::backdrop { background: rgba(4,3,2,.78); backdrop-filter: blur(5px); }
.modal-close { position: absolute; right: 10px; top: 8px; border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; }
.modal-dialog h2 { margin-bottom: 14px; }
.modal-dialog p { line-height: 1.6; color: #c7bba3; }
.reward-dialog { text-align: center; }
.reward-dialog strong { display: block; color: var(--amber); font: 700 clamp(38px, 8vw, 68px)/1 ui-monospace, monospace; letter-spacing: .12em; margin: 18px 0 28px; }
.reward-stamp { display: inline-block; color: #8eb07b; border: 2px solid #6f8c61; padding: 6px 9px; transform: rotate(-3deg); font: 700 10px/1 monospace; letter-spacing: .16em; }
.wide-dialog { width: min(800px, calc(100% - 28px)); }
.pattern-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 25px; }
.tile-pattern { min-height: 125px; border: 4px solid #1f1a13; outline: 1px solid var(--paper-dark); cursor: pointer; background-color: #c9ad68; transition: .2s ease; }
.tile-pattern:hover { transform: translateY(-3px); outline-color: var(--amber); }
.pattern-grid { background-image: linear-gradient(#5b472c 2px, transparent 2px), linear-gradient(90deg,#5b472c 2px, transparent 2px); background-size: 24px 24px; }
.pattern-wave { background-image: radial-gradient(ellipse at top, transparent 60%, #2d4560 61% 68%, transparent 69%); background-size: 36px 24px; }
.pattern-fleur { background-image: radial-gradient(circle at 50% 25%, #26394c 0 5px, transparent 6px), radial-gradient(ellipse at 35% 53%, #26394c 0 6px, transparent 7px), radial-gradient(ellipse at 65% 53%, #26394c 0 6px, transparent 7px), linear-gradient(45deg, transparent 45%, #26394c 46% 53%, transparent 54%); background-size: 42px 42px; }
.pattern-star { background-image: conic-gradient(from 45deg, #2d4560 0 12.5%, transparent 12.5% 25%, #2d4560 25% 37.5%, transparent 37.5% 50%, #2d4560 50% 62.5%, transparent 62.5% 75%, #2d4560 75% 87.5%, transparent 87.5%); background-size: 42px 42px; }
.pattern-circle { background-image: radial-gradient(circle, transparent 0 8px, #2d4560 9px 12px, transparent 13px); background-size: 38px 38px; }
.pattern-chevron { background-image: linear-gradient(135deg, #2d4560 25%, transparent 25%), linear-gradient(225deg, #2d4560 25%, transparent 25%); background-size: 34px 34px; }
.gm-actions { display: grid; gap: 9px; }
.gm-actions button { padding: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.035); cursor: pointer; font: 700 10px/1 monospace; letter-spacing: .1em; }
.gm-note { color: var(--muted)!important; font-size: 12px; margin-top: 18px; }

.success-screen { text-align: center; background: radial-gradient(circle at center, rgba(111,140,97,.18), transparent 55%); }
.success-screen h1 { margin: 12px auto 18px; }
.success-screen p { color: #c8bda7; font-size: 19px; }
.success-code { display: inline-block; border: 1px solid rgba(111,140,97,.55); padding: 14px 18px; color: #a9c497; font: 700 12px/1 monospace; letter-spacing: .12em; margin: 15px 0 28px; }
.success-signal { height: 80px; display: flex; justify-content: center; align-items: center; gap: 6px; }
.success-signal span { width: 5px; background: #86a873; animation: signal 1.1s ease-in-out infinite; }
.success-signal span:nth-child(1) { height: 22px; } .success-signal span:nth-child(2) { height: 52px; animation-delay: .12s; } .success-signal span:nth-child(3) { height: 78px; animation-delay: .24s; } .success-signal span:nth-child(4) { height: 45px; animation-delay: .36s; } .success-signal span:nth-child(5) { height: 25px; animation-delay: .48s; }

@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes signal { 0%,100% { transform: scaleY(.55); opacity: .55; } 50% { transform: scaleY(1); opacity: 1; } }

@media (max-width: 850px) {
  .screen { padding: 24px 16px 120px; }
  .rules-grid, .module-grid, .puzzle-layout, .comms-grid { grid-template-columns: 1fr; }
  .module-card.final-card { grid-column: auto; }
  .module-titlebar { grid-template-columns: auto 1fr; }
  .module-badge { display: none; }
  .desk-grid { min-height: 420px; }
  .final-controls { grid-template-columns: 1fr 1fr; }
  .wide-control { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px 12px; }
  .brand small { display: none; }
  .brand strong { font-size: 10px; }
  .brand-mark { width: 35px; }
  .timer-block { min-width: 84px; padding-right: 9px; }
  .timer-block strong { font-size: 20px; }
  .icon-button { padding: 10px 8px; font-size: 8px; }
  .rules-grid { grid-template-columns: 1fr; }
  h1 { font-size: 42px; }
  .module-titlebar { gap: 12px; }
  .module-titlebar h2 { font-size: 25px; }
  .back-button { padding: 10px 8px; }
  .desk-grid { min-height: 350px; gap: 6px; padding: 10px; }
  .desk-slot { min-height: 80px; }
  .token-bank, .honors-choices { grid-template-columns: 1fr 1fr; }
  .honors-sequence, .color-sequence { gap: 5px; }
  .sequence-slot { min-height: 82px; }
  .final-controls { grid-template-columns: 1fr; }
  .wide-control { grid-column: auto; }
  .pattern-choices { grid-template-columns: repeat(2, 1fr); }
}
