/* Lexlet — same TOKEHUNT palette as the other Academy drills: navy, cyan, lime. */

:root {
  --navy: #04101d;
  --panel: #081a2e;
  --panel-edge: #14374f;
  --cyan: #3fd9ff;
  --cyan-dim: #8fb3c7;
  --lime: #b8f235;
  --danger: #ff5470;
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: #dff3ff;
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: .06em;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#gameShell { position: fixed; inset: 0; }
.hidden { display: none !important; }

/* ----------------------------------------------------------- game screen --- */

#gameScreen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  max-width: 460px;
  margin: 0 auto;
  background:
    linear-gradient(180deg, #08203a 0%, #04101d 55%, #030b14 100%);
}

#topBar { display: flex; gap: 8px; justify-content: space-between; }
.chip {
  background: rgba(8,26,46,.82);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--cyan);
  text-transform: uppercase;
}
.chip.mode { color: var(--lime); }
.chip.score { min-width: 72px; text-align: right; }

#owlBar { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; min-height: 64px; }
.owlSlot { width: 60px; height: 60px; flex: none; font-size: 44px; line-height: 60px; text-align: center; }
.owlSlot.big { width: 96px; height: 96px; margin: 0 auto 6px; font-size: 72px; line-height: 96px; }
.owlHost { width: 100%; height: 100%; }
.owlHost canvas { width: 100% !important; height: 100% !important; }
#owlSpeech {
  flex: 1;
  background: rgba(8,26,46,.82);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 11px;
  color: var(--cyan-dim);
  line-height: 1.5;
  position: relative;
}
#owlSpeech::before {
  content: "";
  position: absolute; left: -6px; top: 24px;
  border: 6px solid transparent;
  border-right-color: var(--panel-edge);
  border-left: 0;
}
#owlSpeech.pop { animation: pop .18s ease-out; }
@keyframes pop { 0% { transform: scale(.96); } 100% { transform: scale(1); } }

/* ---------------------------------------------------------------- board --- */

#board {
  --cols: 5;
  flex: 1;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 7px;
  padding: 6px 0;
}
.boardRow { display: grid; grid-template-columns: repeat(var(--cols), auto); gap: 7px; }

.tile {
  width: clamp(46px, 13vw, 60px);
  height: clamp(46px, 13vw, 60px);
  border: 2px solid var(--panel-edge);
  border-radius: 10px;
  background: rgba(8,26,46,.6);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(20px, 6vw, 26px);
  color: #dff3ff;
  text-transform: uppercase;
  position: relative;
  transition: transform .12s ease, background .18s ease, border-color .18s ease;
}
.tile.filled { border-color: var(--cyan-dim); transform: scale(1.04); }
.tile.reveal { animation: flip .32s ease; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(88deg); } 100% { transform: rotateX(0); } }

.tile.hit  { background: linear-gradient(180deg, #96dd3f, #7dc832); border-color: #7dc832; color: #0c2405; }
.tile.near { background: rgba(63,217,255,.16); border-color: var(--cyan); color: var(--cyan); }
.tile.miss { background: rgba(4,16,29,.85); border-color: #0d2233; color: #4d6a7d; }
.tile.hit::after, .tile.near::after {
  content: attr(data-glyph);
  position: absolute; right: 2px; bottom: 1px;
  font-size: 11px;
  filter: drop-shadow(0 0 2px rgba(0,0,0,.6));
}
.tile.solved { animation: bounce .5s ease; box-shadow: 0 0 18px rgba(184,242,53,.5); }
@keyframes bounce { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-8px); } 70% { transform: translateY(2px); } }

.boardRow.shake { animation: shake .4s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

/* ------------------------------------------------------------- keyboard --- */

#keyboard { display: flex; flex-direction: column; gap: 6px; padding-bottom: 2px; }
.keyRow { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1;
  max-width: 42px;
  height: 52px;
  font: inherit;
  font-size: 14px;
  color: #dff3ff;
  background: #14374f;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
}
.key.wide { max-width: 64px; font-size: 10.5px; }
.key:active { filter: brightness(1.35); }
.key.hit  { background: linear-gradient(180deg, #96dd3f, #7dc832); color: #0c2405; }
.key.near { background: rgba(63,217,255,.28); color: var(--cyan); }
.key.miss { background: #081826; color: #3d5568; }

/* ------------------------------------------------------------- overlays --- */

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(2,8,16,.86);
  z-index: 5;
}

.panel {
  width: min(360px, 100%);
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.55), inset 0 0 40px rgba(63,217,255,.04);
  text-transform: uppercase;
}

h1 { font-size: 38px; line-height: 1; color: var(--cyan); text-shadow: 0 0 18px rgba(63,217,255,.6); }
h1 span { color: var(--lime); text-shadow: 0 0 18px rgba(184,242,53,.55); }
h2 { font-size: 19px; color: var(--cyan); text-shadow: 0 0 14px rgba(63,217,255,.55); margin-bottom: 10px; }
.tagline { margin: 8px 0 8px; font-size: 11px; color: var(--cyan-dim); letter-spacing: .28em; }
.lore { font-size: 10px; color: var(--cyan-dim); line-height: 1.6; margin-bottom: 12px; text-transform: none; }

.howList { list-style: none; text-align: left; margin-bottom: 14px; }
.howList li { font-size: 10.5px; color: var(--cyan-dim); padding: 4px 0; }
.howList b { color: var(--cyan); margin-right: 6px; }
.howList b.good { color: var(--lime); }
.howList b.bad { color: var(--danger); }

.rankRow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.rankCard { background: rgba(4,16,29,.7); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 8px 10px 10px; text-align: left; }
.rankCard span { display: block; font-size: 9px; color: var(--cyan-dim); }
.rankCard strong { display: block; font-size: 13px; color: var(--lime); margin: 2px 0 6px; }

.xpBar { height: 8px; border-radius: 4px; background: #0a2036; border: 1px solid var(--panel-edge); overflow: hidden; }
.xpBar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #6fb52a, var(--lime)); box-shadow: 0 0 10px rgba(184,242,53,.6); transition: width .9s cubic-bezier(.2,.7,.2,1); }

.bestCard { background: rgba(4,16,29,.7); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 9px 12px 11px; margin-bottom: 16px; }
.bestCard span { font-size: 10px; color: var(--cyan-dim); }
.bestCard strong { display: block; font-size: 27px; color: var(--cyan); text-shadow: 0 0 14px rgba(63,217,255,.5); }
.bestCard small { font-size: 10px; color: var(--lime); }

.primaryBtn {
  width: 100%;
  font: inherit; letter-spacing: .14em; text-transform: uppercase;
  font-size: 17px;
  color: #0c2405;
  background: linear-gradient(180deg, #96dd3f, #7dc832);
  border: 0; border-radius: 12px;
  padding: 14px 0;
  box-shadow: 0 5px 0 #47761a, 0 10px 24px rgba(125,200,50,.35);
  cursor: pointer;
}
.primaryBtn:active { transform: translateY(3px); box-shadow: 0 2px 0 #47761a; }

.secondaryBtn {
  font: inherit; letter-spacing: .12em; text-transform: uppercase;
  font-size: 12px;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--panel-edge); border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
}

/* -------------------------------------------------------------- results --- */

.compactPanel { padding: 18px 18px 16px; }
.scoreLine { font-size: 40px; color: var(--cyan); text-shadow: 0 0 16px rgba(63,217,255,.55); margin-bottom: 6px; }

.gradeBadge {
  width: 58px; height: 58px; line-height: 56px;
  margin: 0 auto 12px;
  font-size: 30px;
  color: #0c2405;
  background: linear-gradient(180deg, #96dd3f, #7dc832);
  border-radius: 14px;
  box-shadow: 0 0 22px rgba(184,242,53,.45);
}

#lessonRows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.lessonRow {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(4,16,29,.7);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--lime);
}
.lessonRow em { font-style: normal; font-size: 12px; color: var(--cyan-dim); }
.lessonRow.missed { color: var(--danger); }
.lessonRow.missed em { color: var(--danger); }

.xpRow { display: flex; justify-content: center; gap: 12px; font-size: 11px; color: var(--lime); margin-bottom: 8px; flex-wrap: wrap; }
.rankUp { font-size: 11px; color: var(--lime); margin-bottom: 6px; animation: flashText .5s steps(2) infinite; }
.newBest { color: var(--lime); font-size: 13px; margin-bottom: 6px; animation: flashText .6s steps(2) infinite; }
.owlLine { font-size: 10px; color: var(--cyan-dim); margin-bottom: 8px; text-transform: none; }
.retryHint { font-size: 10px; color: var(--cyan-dim); letter-spacing: .18em; margin-bottom: 12px; }
@keyframes flashText { 50% { filter: brightness(1.6); } }
