:root {
  --bg: #0a0a0f; --surface: #13131a; --border: #2a2a3a;
  --text: #e8e8f0; --muted: #555570;
  --up: #ff6b6b; --down: #4f9fff; --exact: #4fffb0; --accent: #7b6fff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Space Mono', monospace;
  height: 100dvh; max-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; overflow: hidden;
  touch-action: manipulation;
}
button { touch-action: manipulation; }
body::before {
  content: ''; position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(123,111,255,0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(79,255,176,0.04) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}
header { width:100%; max-width:480px; display:flex; justify-content:space-between; align-items:center; padding:8px 0 16px; position:relative; z-index:1; }
.header-actions { display:flex; align-items:center; gap:8px; }
.logo { font-family:'Bebas Neue',sans-serif; font-size:42px; letter-spacing:6px; background:linear-gradient(135deg,var(--accent),var(--up)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; cursor:default; user-select:none; }
.kt-toggle {
  background:none; border:1px solid var(--border); color:var(--muted);
  font-family:'Space Mono',monospace; font-size:18px; line-height:1;
  padding:6px 10px; cursor:pointer; border-radius:4px; transition:all 0.2s;
  display:flex; align-items:center; justify-content:center; min-width:40px;
}
.kt-toggle:hover { border-color:var(--accent); color:var(--accent); }
.kt-toggle:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.help-btn { background:none; border:1px solid var(--border); color:var(--muted); font-family:'Space Mono',monospace; font-size:12px; padding:6px 12px; cursor:pointer; border-radius:4px; transition:all 0.2s; letter-spacing:1px; }
.help-btn:hover { border-color:var(--accent); color:var(--accent); }
.subtitle { color:var(--muted); font-size:11px; letter-spacing:3px; text-transform:uppercase; margin-bottom:28px; position:relative; z-index:1; text-align:center; }
.legend { display:flex; gap:20px; margin-bottom:28px; font-size:11px; color:var(--muted); letter-spacing:1px; position:relative; z-index:1; }
.legend-item { display:flex; align-items:center; gap:6px; }
.legend-arrow { font-size:14px; font-weight:bold; }
#game-board { width:100%; max-width:480px; display:flex; flex-direction:column; gap:8px; margin-bottom:20px; position:relative; z-index:1; }
.row { display:grid; grid-template-columns:repeat(5,1fr); gap:8px; }
.cell { aspect-ratio:1; border:1px solid var(--border); background:var(--surface); display:flex; flex-direction:column; align-items:center; justify-content:center; font-family:'Bebas Neue',sans-serif; font-size:28px; position:relative; border-radius:4px; transition:border-color 0.15s; }
.cell .arrow { position:absolute; top:4px; right:6px; font-size:11px; font-weight:bold; font-family:'Space Mono',monospace; }
.cell.up    { border-color:var(--up);    color:var(--up);    } .cell.up    .arrow { color:var(--up);    }
.cell.down  { border-color:var(--down);  color:var(--down);  } .cell.down  .arrow { color:var(--down);  }
.cell.exact { border-color:var(--exact); color:var(--exact); } .cell.exact .arrow { color:var(--exact); }
@keyframes reveal { 0%{transform:scaleY(1)} 50%{transform:scaleY(0)} 100%{transform:scaleY(1)} }
.cell.revealed { animation:reveal 0.4s ease forwards; }
@keyframes pop { 0%{transform:scale(1)} 50%{transform:scale(1.12)} 100%{transform:scale(1)} }
.cell.pop { animation:pop 0.15s ease; }
.input-row { display:grid; grid-template-columns:repeat(5,1fr); gap:8px; margin-bottom:16px; width:100%; max-width:480px; position:relative; z-index:1; }
.input-cell { aspect-ratio:1; border:1px solid var(--border); background:var(--surface); display:flex; align-items:center; justify-content:center; font-family:'Bebas Neue',sans-serif; font-size:28px; border-radius:4px; transition:border-color 0.15s; }
.input-cell.active { border-color:var(--accent); }
.input-cell.has-letter { border-color:#3a3a5a; color:var(--text); }
.keyboard { width:100%; max-width:480px; display:flex; flex-direction:column; gap:8px; position:relative; z-index:1; }
.kb-row { display:flex; justify-content:center; gap:6px; }
.key { background:var(--surface); border:1px solid var(--border); color:var(--text); font-family:'Space Mono',monospace; font-size:12px; font-weight:700; width:40px; height:48px; cursor:pointer; border-radius:4px; transition:all 0.15s; display:flex; align-items:center; justify-content:center; }
.key:hover { border-color:var(--accent); }
.key.wide { width:60px; font-size:10px; }
.key.in-range {
  border-color: var(--exact);
  box-shadow: 0 0 6px rgba(79,255,176,0.35);
}
.key.out-of-range {
  border-color: #1a1a26;
  color: #252535;
  background: #0a0a10;
  box-shadow: none;
}
#message { height:32px; display:flex; align-items:center; justify-content:center; font-size:13px; letter-spacing:2px; color:var(--muted); margin-bottom:8px; position:relative; z-index:1; width:100%; max-width:480px; text-align:center; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-6px)} 80%{transform:translateX(6px)} }
#message.shake { animation:shake 0.4s ease; }
.end-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.end-panel.show { display: flex; }
.end-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.end-title { font-family:'Bebas Neue',sans-serif; font-size:48px; letter-spacing:6px; }
.end-title.win  { color:var(--exact); }
.end-title.lose { color:var(--down);  }
.end-word { color:var(--muted); font-size:12px; letter-spacing:3px; }
.end-def { font-size:12px; color:var(--text); opacity:0.65; max-width:260px; margin:10px auto 0; line-height:1.6; font-style:italic; min-height:18px; }
.end-name { font-size:11px; letter-spacing:2px; opacity:0.45; margin:18px auto 6px; text-transform:uppercase; }
.share-btn,.play-again-btn { font-family:'Space Mono',monospace; font-size:12px; font-weight:700; letter-spacing:2px; padding:12px 24px; border-radius:4px; cursor:pointer; border:none; transition:all 0.2s; }
.share-btn { background:var(--exact); color:var(--bg); }
.share-btn:hover { opacity:0.85; transform:translateY(-1px); }
.play-again-btn { background:transparent; border:1px solid var(--border); color:var(--muted); }
.play-again-btn:hover { border-color:var(--accent); color:var(--accent); }
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:100; align-items:center; justify-content:center; }
.modal-overlay.show { display:flex; }
.modal { background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:32px; max-width:380px; width:90%; }
.modal h2 { font-family:'Bebas Neue',sans-serif; font-size:32px; letter-spacing:4px; margin-bottom:20px; background:linear-gradient(135deg,var(--accent),var(--up)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }
.modal p { font-size:12px; line-height:1.8; color:var(--muted); margin-bottom:14px; letter-spacing:0.5px; }
.modal-example { display:flex; gap:6px; margin:12px 0; }
.ex-cell { width:44px; height:44px; border-radius:4px; display:flex; flex-direction:column; align-items:center; justify-content:center; font-family:'Bebas Neue',sans-serif; font-size:20px; position:relative; border:1px solid var(--border); }
.ex-cell .ex-arrow { position:absolute; top:2px; right:4px; font-size:9px; font-family:'Space Mono',monospace; font-weight:bold; }
.ex-cell.up    { border-color:var(--up);    color:var(--up);    } .ex-cell.up    .ex-arrow { color:var(--up);    }
.ex-cell.down  { border-color:var(--down);  color:var(--down);  } .ex-cell.down  .ex-arrow { color:var(--down);  }
.ex-cell.exact { border-color:var(--exact); color:var(--exact); } .ex-cell.exact .ex-arrow { color:var(--exact); }
.close-modal { margin-top:20px; background:var(--accent); color:white; border:none; font-family:'Space Mono',monospace; font-size:12px; font-weight:700; letter-spacing:2px; padding:10px 24px; border-radius:4px; cursor:pointer; width:100%; }
#toast { position:fixed; bottom:40px; left:50%; transform:translateX(-50%) translateY(20px); background:var(--up); color:var(--bg); font-family:'Space Mono',monospace; font-size:11px; font-weight:700; letter-spacing:2px; padding:10px 20px; border-radius:4px; opacity:0; transition:all 0.3s; z-index:200; pointer-events:none; }
#toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

#scroll-area {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 20px 8px;
  min-height: 0;
  background: var(--bg);
}
#keyboard-wrap {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 8px 20px 20px;
  background: var(--bg);
}
