:root {
  --bg: #090d12;
  --panel: #0f151d;
  --panel-2: #151e28;
  --line: #2b3745;
  --text: #f4f7fa;
  --muted: #8593a3;
  --correct: #28b36b;
  --present: #d4a72c;
  --absent: #394552;
  --accent: #d8f70a;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.app { height: 100dvh; display: grid; grid-template-columns: 40% 60%; background: radial-gradient(circle at 10% 0%, #172331 0, transparent 38%), var(--bg); }
.board-side, .controls-side { min-width: 0; padding: clamp(22px, 2.2vw, 44px); }
.board-side { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.controls-side { display: flex; flex-direction: column; justify-content: space-between; background: rgba(15,21,29,.92); }
.topbar, .control-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-weight: 800; letter-spacing: .18em; font-size: clamp(10px, .72vw, 14px); }
h1 { font-size: clamp(30px, 2.5vw, 48px); line-height: .9; margin: 0; letter-spacing: -.05em; }
h1 span { color: var(--accent); }
h2 { font-size: clamp(26px, 2vw, 40px); margin: 0; letter-spacing: -.035em; }
.header-actions { display: flex; align-items: stretch; gap: 10px; }
.day-chip { min-width: 135px; border: 1px solid var(--line); background: var(--panel); border-radius: 13px; padding: 8px 13px; display: flex; flex-direction: column; justify-content: center; }
.day-chip span { font-weight: 850; font-size: 16px; }
.day-chip small { color: var(--muted); font-size: 9px; letter-spacing: .08em; margin-top: 2px; }
.icon-button, .modal-close { border: 1px solid var(--line); background: var(--panel); border-radius: 13px; width: 52px; min-height: 52px; font-weight: 850; font-size: 22px; cursor: pointer; }
.icon-button:active, .new-game:active, .key:active { transform: scale(.97); filter: brightness(1.15); }
.message { height: 30px; margin: 8px 0 2px; text-align: center; font-size: 14px; font-weight: 750; color: var(--accent); letter-spacing: .03em; }
.grid-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
.grid { --tile: min(8.2vh, 5vw); display: grid; grid-template-columns: repeat(5, var(--tile)); grid-template-rows: repeat(6, var(--tile)); gap: clamp(7px, .58vw, 11px); }
.tile { width: var(--tile); height: var(--tile); display: grid; place-items: center; border: 2px solid var(--line); border-radius: 9px; background: rgba(13,18,24,.7); font-size: calc(var(--tile) * .47); font-weight: 850; text-transform: uppercase; perspective: 500px; }
.tile.filled { border-color: #677687; animation: pop .11s ease-out; }
.tile.reveal { animation: flip .5s ease forwards; }
.tile.correct { background: var(--correct); border-color: var(--correct); }
.tile.present { background: var(--present); border-color: var(--present); }
.tile.absent { background: var(--absent); border-color: var(--absent); }
.tile.shake { animation: shake .35s; }
.board-footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; color: var(--muted); font-size: clamp(9px, .68vw, 13px); font-weight: 750; letter-spacing: .08em; }
.legend { display: flex; gap: 8px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.legend .correct { background: var(--correct); }.legend .present { background: var(--present); }
.new-game { border: 1px solid #51600c; background: rgba(216,247,10,.08); color: var(--accent); border-radius: 14px; padding: 15px 22px; font-weight: 850; font-size: 13px; letter-spacing: .1em; cursor: pointer; }
.keyboard { display: grid; gap: clamp(8px, .8vw, 15px); padding: 2vh 0; }
.key-row { display: flex; justify-content: center; gap: clamp(8px, .72vw, 15px); }
.key { position: relative; flex: 1 1 0; max-width: 94px; height: clamp(70px, 10.5vh, 112px); padding: 0; border: 1px solid #354554; border-radius: 14px; background: #293541; box-shadow: inset 0 -5px 0 rgba(0,0,0,.25); font-weight: 850; font-size: clamp(20px, 1.7vw, 33px); cursor: pointer; transition: transform .08s, background .2s, opacity .2s; }
.key.wide { flex: 1.65 1 0; max-width: 155px; font-size: clamp(12px, 1vw, 19px); letter-spacing: .03em; }
.key.correct { background: var(--correct); border-color: #34d17f; }.key.present { background: var(--present); border-color: #f0c94e; }.key.absent { background: #141b22; border-color: #222c36; color: #56616c; opacity: .42; box-shadow: none; }
.key.absent::after { content:""; position:absolute; left:18%; right:18%; top:50%; height:3px; border-radius:2px; background:#74808b; transform:rotate(-35deg); opacity:.7; }
.quick-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.quick-stats div { min-width: 0; background: var(--panel-2); padding: clamp(12px, 1.3vw, 22px) 8px; text-align: center; }
.quick-stats strong { display: block; font-size: clamp(19px, 1.65vw, 32px); line-height: 1; }
.quick-stats span { display: block; margin-top: 7px; color: var(--muted); font-size: clamp(8px, .62vw, 12px); font-weight: 750; letter-spacing: .08em; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.76); backdrop-filter: blur(10px); }
.modal-backdrop[hidden] { display: none; }
.modal { position: relative; width: min(780px, 92vw); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 22px; background: #111821; box-shadow: 0 30px 90px #000; padding: clamp(28px, 3vw, 48px); }
.modal-close { position: absolute; top: 18px; right: 18px; }
.modal h3 { margin: 0 64px 5px 0; font-size: 34px; }.modal .sub { color: var(--muted); margin: 0 0 28px; }
.stats-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 8px; margin: 22px 0; }.stats-grid div { background: var(--panel-2); border-radius: 12px; padding: 15px 8px; text-align: center; }.stats-grid strong { display: block; font-size: 27px; }.stats-grid span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.distribution { display: grid; gap: 7px; }.bar-row { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 8px; font-weight: 800; }.bar { min-width: 30px; padding: 7px 9px; border-radius: 5px; background: var(--absent); text-align: right; font-size: 12px; }.bar.best { background: var(--correct); }
.analysis-card { margin-top: 24px; border-left: 4px solid var(--accent); background: rgba(216,247,10,.06); border-radius: 0 12px 12px 0; padding: 16px 18px; }.analysis-card strong { color: var(--accent); }.analysis-card p { margin: 6px 0 0; color: #c6d0da; line-height: 1.5; }
.share-button { width: 100%; margin-top: 24px; padding: 17px; border: 0; border-radius: 12px; background: var(--accent); color: #111; font-weight: 900; cursor: pointer; }
.modal-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:24px; }.modal-actions .share-button { margin-top:0; }.next-button { width:100%; padding:17px; border:1px solid #51600c; border-radius:12px; background:rgba(216,247,10,.08); color:var(--accent); font-weight:900; cursor:pointer; }
.examples { display:flex; gap:8px; margin: 22px 0; }.examples .tile { --tile: 54px; }
.rules { color:#c5ced7; line-height:1.55; }.credit { color:var(--muted); font-size:12px; margin-top:24px; }
@keyframes pop { 50% { transform: scale(1.08); } } @keyframes flip { 50% { transform: rotateX(90deg); } } @keyframes shake { 20%,60%{transform:translateX(-6px)}40%,80%{transform:translateX(6px)} }
.tile.reveal { animation-duration: .78s; }

@media (max-aspect-ratio: 1/1) {
  html,body { overflow:auto; }.app { min-height:100dvh; height:auto; grid-template-columns:1fr; }.board-side { min-height:56dvh; border-right:0; border-bottom:1px solid var(--line); }.controls-side { min-height:44dvh; }.grid { --tile:min(8vh,14vw); }.key { height:58px; }.legend { display:none; }
}
@media (max-height: 700px) and (min-aspect-ratio: 1/1) { .board-side,.controls-side{padding:18px 28px}.grid{--tile:min(8.5vh,4.8vw)}.key{height:62px}.message{height:22px}.quick-stats div{padding:10px 6px} }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; } }
