:root{
  --bg0:#060a16;
  --bg1:#0a1022;
  --stroke: rgba(255,255,255,.12);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.68);

  --accentA: rgba(168,85,247,.92);
  --accentB: rgba(59,130,246,.90);

  --good: rgba(34,197,94,.92);
  --bad: rgba(244,63,94,.88);

  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: system-ui, Segoe UI, Arial;
  background:
    radial-gradient(900px 520px at 20% 10%, rgba(168,85,247,.16), transparent 55%),
    radial-gradient(900px 520px at 85% 20%, rgba(59,130,246,.18), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  color: var(--text);
  overflow: hidden;
  touch-action: none;
}

/* HUD */
.hud{
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 10px calc(12px + var(--sal));
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.brand{ font-weight: 1000; letter-spacing: .2px; }
.sub{ color: var(--muted); font-weight:700; font-size:12px; margin-top:6px; max-width: 52ch; }

.hudRight{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap: wrap;
}

.stat{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  border-radius: 14px;
  padding: 8px 10px;
  min-width: 76px;
}
.label{ color: var(--muted); font-size:11px; font-weight:800; }
.value{ font-size:16px; font-weight:1000; margin-top:2px; }

/* Stage */
.stage{
  position: fixed;
  inset: 0;
  padding-top: calc(62px + var(--sat));
  padding-bottom: calc(74px + var(--sab));
  padding-left: var(--sal);
  padding-right: var(--sar);
  z-index: 1;
}

/* Panel */
.panel{
  position:absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  pointer-events: none;
  z-index: 10;
}

.panelInner{
  pointer-events: auto;
  width: min(560px, calc(100vw - 36px));
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(12px);
  box-shadow: 0 22px 60px rgba(0,0,0,.45);
  padding: 14px;
}

.panelTitle{ font-size: 20px; font-weight: 1000; }
.panelText{ margin-top: 8px; color: var(--muted); font-weight: 700; line-height: 1.35; }

.panelButtons{
  display:flex;
  gap:10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn{
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 12px 14px;
  cursor:pointer;
  font-weight: 1000;
}
.btn.primary{
  background: linear-gradient(135deg, var(--accentA), var(--accentB));
  border-color: rgba(255,255,255,.20);
}
.btn:active{ transform: translateY(1px); }

.pill{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  padding: 6px 10px;
  border-radius: 999px;
  color: rgba(255,255,255,.78);
  font-weight: 900;
  font-size: 12px;
}
.panelHint{
  display:flex;
  gap:8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Main game content */
.game{
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 14px;
}

.card{
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(10px);
  padding: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,.32);
}

.cardTop{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}

.chipMini{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  font-weight: 900;
  font-size: 12px;
}

.chipMini.muted{ color: rgba(255,255,255,.72); }

.target{
  margin-top: 10px;
  font-size: clamp(26px, 7vw, 46px);
  font-weight: 1000;
  letter-spacing: 1px;
  text-align: center;
  padding: 12px 10px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
}

.entryWrap{ margin-top: 10px; }

.entryLabel{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 8px;
}

.hint{ color: rgba(255,255,255,.68); font-weight: 800; font-size: 12px; }

.entry{
  min-height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
  padding: 10px 12px;
  font-weight: 1000;
  letter-spacing: 1px;
  font-size: 20px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.row{
  display:flex;
  gap:10px;
  margin-top: 10px;
}

.miniBtn{
  flex: 1;
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-weight: 1000;
  cursor: pointer;
}
.miniBtn.primary{
  background: linear-gradient(135deg, var(--accentA), var(--accentB));
  border-color: rgba(255,255,255,.20);
}
.miniBtn:active{ transform: translateY(1px); }

.toast{
  margin-top: 10px;
  min-height: 18px;
  text-align: center;
  font-weight: 1000;
  color: rgba(255,255,255,.86);
}

/* On-screen keyboard */
.keys{
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(10px);
  padding: 10px;
  display: grid;
  gap: 8px;
  grid-template-rows: auto auto auto;
  align-content: start;
  box-shadow: 0 18px 40px rgba(0,0,0,.26);
}

.krow{
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
}

.key{
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  color: rgba(255,255,255,.92);
  font-weight: 1000;
  font-size: 14px;
  cursor: pointer;
}
.key:active{ transform: translateY(1px); }
.key.wide{ grid-column: span 2; }
.key.good{ background: rgba(34,197,94,.20); }
.key.bad{ background: rgba(244,63,94,.18); }

/* Bottom actions */
.actions{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px calc(12px + var(--sar)) calc(10px + var(--sab)) calc(12px + var(--sal));
  display:flex;
  gap:10px;
  justify-content: space-between;
  border-top: 1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(10px);
  z-index: 25;
}

.chip{
  flex: 1;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-weight: 1000;
  cursor: pointer;
}
.chip:active{ transform: translateY(1px); }

@media (min-width: 900px){
  .hud{ padding: 12px 14px; }
  .stage{ padding-top: 70px; padding-bottom: 82px; }
  .game{
    max-width: 980px;
    margin: 0 auto;
    grid-template-columns: 1.1fr .9fr;
    grid-template-rows: 1fr;
    gap: 14px;
  }
  .actions{
    max-width: 980px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 18px 18px 0 0;
  }
}
