:root {
  color-scheme: light;
  --paper: #fbf7f1;
  --ink: #29223a;
  --muted: #5c5665;
  --line: #e2d9dc;
  --mint: #bfe1d9;
  --pink: #f8dce9;
  --lime: #c1f64b;
  --mono: "IBM Plex Mono", Consolas, monospace;
  font: 100%/1.5 Inter, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 1030px; margin: auto; padding: 0 clamp(16px, 5vw, 48px) 56px; }
h1, h2, p { margin: 0; }
a { color: inherit; text-underline-offset: 4px; }
header, nav, .brand, .stats, .clock, .entry-row { display: flex; align-items: center; }
header { min-height: 72px; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
nav { gap: clamp(10px, 4vw, 24px); font-size: .9rem; }
.brand { gap: 10px; text-decoration: none; line-height: 1.2; }
.brand b { letter-spacing: -.025em; }
.brand small { font-size: .78rem; margin-top: 3px; }
.brand-icon {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid #dcaec8; border-radius: 50%; background: var(--pink); color: #76385c;
}
.layout { max-width: 730px; margin: 36px auto 0; }
.console { margin-bottom: 24px; }
h1 { font-size: clamp(2.7rem, 7vw, 4.7rem); line-height: 1.05; font-weight: 850; letter-spacing: -.065em; }
h1 span { padding-inline: .08em; background: linear-gradient(transparent 61%, var(--mint) 61% 93%, transparent 93%); }
.intro p { max-width: 57ch; margin: 12px 0 22px; color: var(--muted); }

.display {
  position: relative; overflow: hidden; isolation: isolate;
  border: 6px solid #343831; border-radius: 22px;
  background: radial-gradient(ellipse at center, #252b25, #121611 86%);
  box-shadow: inset 0 0 0 2px #080b08, 0 4px 0 #191c17;
  padding: 17px clamp(16px, 3vw, 28px) 20px; color: #f5f6e9;
}
.stats, .clock { justify-content: space-between; font: .86rem var(--mono); color: #d2d6c7; letter-spacing: .04em; }
.stats b { color: white; margin-left: .4em; }
.stimulus {
  position: relative; overflow: hidden;
  min-height: 170px; display: grid; place-content: center; justify-items: center;
  border-radius: 12px; background-color: var(--word-bg, transparent);
}
#word { font: 800 clamp(2.3rem, 7.3vw, 5rem)/1.13 var(--mono); color: #72a9ff; letter-spacing: -.055em; }
#word { position: relative; z-index: 1; transform: translateX(var(--word-offset, 0px)); }
#cue { position: relative; z-index: 1; }
#pulse { position: absolute; inset: 0; box-shadow: inset 0 0 0 10px #bfe1d9; opacity: 0; pointer-events: none; z-index: 4; }
#decoys { position: absolute; inset: 5px 8px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr 1fr; align-content: space-between; pointer-events: none; opacity: .6; }
#decoys span { font: 600 clamp(.65rem, 2vw, .85rem)/1.1 var(--mono); text-align: center; align-self: start; }
#decoys span:nth-child(n+4) { align-self: end; }
.challenge { font-size: .85rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { #pulse { display: none; } }
#cue { font: .85rem/1.4 var(--mono); color: #e0e1d8; margin-top: 4px; text-align: center; }
#cue.word-rule { background: var(--mint); color: #1c3933; border-radius: 5px; padding: 2px 6px; font-weight: 700; }
#rule-intro { max-width: 38ch; padding: 14px 10px; text-align: center; }
#rule-intro h2 { color: var(--mint); font-size: clamp(1.35rem, 5vw, 2rem); line-height: 1.1; }
#rule-instructions { margin: 9px 0; font-weight: 700; }
#rule-countdown { color: #d2d6c7; font: .9rem var(--mono); font-variant-numeric: tabular-nums; }
.track { height: 6px; background: #484d43; border-radius: 4px; margin-top: 7px; overflow: hidden; }
#bar { height: 100%; background: var(--lime); transform-origin: left; }
#sample { display: flex; gap: 4px; margin: 8px; }
#sample i { background: #ff626c; width: 8px; height: 8px; border-radius: 50%; }
#sample i:nth-child(2) { background: #72a9ff; }
#sample i:nth-child(3) { background: #56db88; }
#sample i:nth-child(4) { background: #ffe24a; }

.controls { margin-top: 22px; }
label { display: block; font-weight: 700; margin-bottom: 7px; }
button, input, textarea { font: inherit; }
input, textarea {
  width: 100%; min-width: 0; border-radius: 9px; border: 1px solid #aaa0ad;
  background: #fffdfb; color: var(--ink); padding: 11px 13px;
}
textarea { resize: vertical; }
button { cursor: pointer; border-radius: 9px; padding: 11px 18px; font-weight: 700; touch-action: manipulation; }
.entry-row { gap: 9px; }
.primary { background: var(--mint); color: #1c3933; border: 1px solid #86b4a8; }
.primary:hover { background: #a9d4c9; }
.secondary { background: transparent; border: 1px solid var(--line); color: var(--ink); }
small { display: block; color: var(--muted); margin-top: 7px; }
:is(button, input, textarea, a, summary):focus-visible { outline: 3px solid #9264a6; outline-offset: 3px; }
button:disabled { cursor: wait; opacity: .7; }
#choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
#choices button {
  color: var(--choice); background: var(--choice-bg, #22251f);
  border: 1px solid color-mix(in srgb, var(--choice-bg, #22251f), white 22%);
  min-height: 52px; font: 700 1.05rem var(--mono); display: flex; align-items: center; gap: 12px;
}
kbd { font: .83rem var(--mono); color: #ddd; border: 1px solid #61675c; border-radius: 3px; padding: 2px 5px; }
.controls p:not(:empty) { margin: 8px 0 12px; }
#notice { color: var(--muted); }
[hidden] { display: none !important; }

#ranking, #mensajitos { border-top: 1px solid var(--line); scroll-margin-top: 18px; }
#ranking > summary, .message-compose > summary {
  display: flex; gap: 8px; align-items: center; list-style: none;
}
summary::-webkit-details-marker { display: none; }
#ranking > summary { padding: 13px 0; }
#ranking > summary small { margin: 0 0 0 auto; font-weight: 400; }
:is(#ranking, .message-compose) > summary::before { content: "+"; color: #76426a; width: 1rem; }
:is(#ranking, .message-compose)[open] > summary::before { content: "−"; }
.ranking-body { padding: 0 0 16px; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 3px 0 9px; text-align: left; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 3px; border-bottom: 1px solid var(--line); }
th { font-size: .85rem; color: var(--muted); }
th:first-child, th:last-child { width: 20%; }
td:nth-child(2) { overflow-wrap: anywhere; }
.num { text-align: right; }
#board-note, .ranking-body details p { color: var(--muted); font-size: .94rem; }
.ranking-body details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 650; }
details p + p { margin-top: 8px; }

#mensajitos { padding-top: 18px; }
.message-heading { margin-bottom: 10px; }
#mensajitos h2, #outcome { font-size: 1.45rem; letter-spacing: -.045em; }
.message-heading p, #message-list-note, #message-feedback { color: var(--muted); }
.message-compose > summary { width: fit-content; background: var(--pink); border-radius: 8px; padding: 7px 12px; }
#message-form { margin-top: 14px; }
#message-form label:not(:first-child) { margin-top: 12px; }
#message-form button { margin: 10px 0; }
.message-list { list-style: none; margin: 10px 0 0; padding: 0; }
.message-list li { margin-top: 8px; padding: 10px 12px; background: #fffdfb; border-left: 3px solid var(--mint); }
.message-list p { white-space: pre-wrap; overflow-wrap: anywhere; }
#message-list-note, #message-feedback { font-size: .9rem; margin-top: 8px; }

@media (max-width: 650px) {
  .layout { margin-top: 24px; }
  header { min-height: 61px; }
  .brand-icon { width: 30px; height: 30px; }
  .brand small { display: none; }
  .stimulus { min-height: 125px; }
  .display { padding: 14px; }
  body.playing .intro p { display: none; }
  body.playing .intro h1 { font-size: 2.25rem; margin-bottom: 14px; }
  #choices button { gap: 8px; padding: 12px; font-size: clamp(.9rem, 4vw, 1.05rem); }
  .controls { margin-top: 16px; }
}
