* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --orange: #FF8A3D;
  --orange-deep: #FF6A12;
  --cyan: #22E8FF;
  --magenta: #FF3FCB;
  --green: #49F5A2;
  --ink: #05040C;
  --panel: rgba(14, 12, 30, 0.82);
  --line: rgba(34, 232, 255, 0.16);
  --line-strong: rgba(34, 232, 255, 0.34);
  --text: #EAF2FF;
  --dim: #7C86A8;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #05040C;
  color: var(--text);
  font-family: var(--sans);
}

body {
  background:
    radial-gradient(120% 70% at 50% -8%, rgba(255, 138, 61, 0.16), transparent 58%),
    radial-gradient(90% 60% at 108% 102%, rgba(255, 63, 203, 0.12), transparent 62%),
    radial-gradient(80% 55% at -12% 78%, rgba(34, 232, 255, 0.10), transparent 60%),
    #05040C;
}

#shell {
  position: fixed;
  inset: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 560px;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  isolation: isolate;
}

#shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(100% 60% at 50% 46%, transparent 38%, rgba(2, 1, 8, 0.55) 100%),
    linear-gradient(180deg, rgba(3, 2, 9, 0.35), transparent 22%, transparent 82%, rgba(3, 2, 9, 0.5));
}

#shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(140, 200, 255, 0.045) 0 1px, transparent 1px 3px);
  opacity: 0.45;
}

#bgfx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.9;
  pointer-events: none;
}

/* ---------------- HUD ---------------- */

.hud {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 8px 12px 0;
  flex: none;
}

.stats {
  display: flex;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.stat {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 5px 9px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(22, 19, 44, 0.9), rgba(9, 8, 21, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 6px 18px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34, 232, 255, 0.65), transparent);
  opacity: 0.55;
}

.stat-k {
  display: block;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--dim);
  line-height: 1.1;
  white-space: nowrap;
}

.stat-v {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: clamp(15px, 4.6vw, 20px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-score { flex: 1.4; }

.stat-score .stat-v {
  color: var(--orange);
  text-shadow: 0 0 14px rgba(255, 138, 61, 0.55);
}

.stat-score.bump .stat-v {
  animation: scoreBump 0.28s ease-out;
}

@keyframes scoreBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); color: #FFD0AE; }
  100% { transform: scale(1); }
}

.hud-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.icon-btn {
  width: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(22, 19, 44, 0.9), rgba(9, 8, 21, 0.9));
  color: #C8D6FF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn .mp-icon { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.92); border-color: var(--line-strong); box-shadow: 0 0 16px rgba(34, 232, 255, 0.22); }

/* ---------------- Tray (next / hold) ---------------- */

.tray {
  position: relative;
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 8px 12px 0;
  flex: none;
}

.tray-card {
  height: 56px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 16, 38, 0.85), rgba(8, 7, 19, 0.88));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 8px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  min-width: 0;
}

.tray-next { flex: 1; }

.tray-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--dim);
  flex: none;
  padding-top: 1px;
}

.cv-wrap {
  display: block;
  position: relative;
  height: 44px;
  min-width: 0;
}

.next-wrap { flex: 1; min-width: 0; }
.hold-wrap { width: 44px; flex: none; }

.cv-wrap canvas { display: block; width: 100%; height: 100%; }

.tray-hold {
  flex: none;
  width: 102px;
  padding: 0 8px;
  gap: 7px;
  color: var(--text);
  font-family: var(--sans);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tray-hold:active,
.tray-hold.pressed {
  transform: scale(0.96);
  border-color: rgba(255, 138, 61, 0.55);
  box-shadow: 0 0 20px rgba(255, 138, 61, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tray-hold.used { opacity: 0.62; }

/* ---------------- Board ---------------- */

.arena {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
}

.board-frame {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(34, 232, 255, 0.32);
  background: rgba(5, 4, 14, 0.94);
  box-shadow:
    0 0 0 1px rgba(34, 232, 255, 0.06),
    0 0 34px rgba(34, 232, 255, 0.13),
    0 18px 44px rgba(0, 0, 0, 0.55),
    inset 0 0 44px rgba(6, 24, 48, 0.55);
}

#board {
  display: block;
  border-radius: 13px;
}

.corner {
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid var(--orange);
  opacity: 0.92;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(255, 138, 61, 0.75));
  z-index: 2;
}

.c-tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.c-tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.c-bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.c-br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }

.toast {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-family: var(--sans);
  font-size: clamp(22px, 7.5vw, 34px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.04em;
  color: #FFFFFF;
  text-shadow: 0 0 12px rgba(255, 138, 61, 0.95), 0 0 32px rgba(255, 106, 18, 0.6);
  white-space: nowrap;
}

.toast small {
  display: block;
  margin-top: 2px;
  font-size: 0.42em;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(34, 232, 255, 0.8);
}

.toast.show { animation: toastPop 0.95s cubic-bezier(0.2, 0.8, 0.3, 1) forwards; }

@keyframes toastPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
  16%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  30%  { transform: translate(-50%, -50%) scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -74%) scale(1); }
}

/* ---------------- Pad ---------------- */

.pad {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  gap: 7px;
  padding: 9px 10px calc(11px + env(safe-area-inset-bottom, 0px));
}

.key {
  flex: 1;
  min-width: 0;
  height: 60px;
  border-radius: 14px;
  border: 1px solid rgba(34, 232, 255, 0.24);
  background: linear-gradient(180deg, rgba(28, 24, 56, 0.95), rgba(10, 8, 23, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 7px 18px rgba(0, 0, 0, 0.32);
  color: #DDE6FF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  font-family: var(--sans);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.07s ease, background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.key .mp-icon {
  width: 25px;
  height: 25px;
  color: #E4ECFF;
  filter: drop-shadow(0 0 6px rgba(34, 232, 255, 0.35));
}

.key span {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.key:active,
.key.is-down {
  transform: scale(0.94);
  border-color: rgba(34, 232, 255, 0.6);
  background: linear-gradient(180deg, rgba(34, 232, 255, 0.18), rgba(9, 8, 23, 0.96));
  box-shadow: 0 0 22px rgba(34, 232, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.key-rotate {
  border-color: rgba(255, 138, 61, 0.42);
  background: linear-gradient(180deg, rgba(66, 32, 18, 0.85), rgba(20, 10, 6, 0.95));
}

.key-rotate .mp-icon { color: var(--orange); filter: drop-shadow(0 0 8px rgba(255, 138, 61, 0.55)); }

.key-rotate:active,
.key-rotate.is-down {
  border-color: var(--orange);
  background: linear-gradient(180deg, rgba(255, 138, 61, 0.32), rgba(30, 14, 8, 0.95));
  box-shadow: 0 0 24px rgba(255, 138, 61, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.key-drop .mp-icon { color: var(--cyan); }

/* ---------------- Overlays ---------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(70% 50% at 50% 42%, rgba(12, 10, 30, 0.55), rgba(3, 2, 10, 0.93) 78%);
  -webkit-backdrop-filter: blur(7px) saturate(1.1);
  backdrop-filter: blur(7px) saturate(1.1);
  opacity: 1;
  visibility: visible;
  overflow-y: auto;
  touch-action: pan-y;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.card {
  width: 100%;
  max-width: 336px;
  margin: auto;
  border-radius: 22px;
  border: 1px solid rgba(34, 232, 255, 0.26);
  background:
    linear-gradient(180deg, rgba(24, 20, 48, 0.94), rgba(8, 6, 19, 0.97));
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.65),
    0 0 44px rgba(34, 232, 255, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  padding: 26px 22px 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.8;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(80% 40% at 50% 0%, rgba(255, 138, 61, 0.10), transparent 70%);
}

/* logo */

.logo-mark {
  display: grid;
  grid-template-columns: repeat(3, 17px);
  grid-template-rows: repeat(2, 17px);
  gap: 4px;
  justify-content: center;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
  animation: markFloat 3.6s ease-in-out infinite;
}

.lm {
  display: block;
  border-radius: 4px;
  background: linear-gradient(180deg, #7CF4FF, #12B9D8);
  box-shadow: 0 0 12px rgba(34, 232, 255, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  opacity: 0.95;
}

.lm-t { grid-area: 1 / 2; background: linear-gradient(180deg, #FFC08A, #FF6A12); box-shadow: 0 0 12px rgba(255, 138, 61, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.lm-l { grid-area: 2 / 1; background: linear-gradient(180deg, #FF9BDF, #E01F9E); box-shadow: 0 0 12px rgba(255, 63, 203, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.lm-c { grid-area: 2 / 2; background: linear-gradient(180deg, #7CF4FF, #12B9D8); }
.lm-r { grid-area: 2 / 3; background: linear-gradient(180deg, #A6FFD0, #12C97B); box-shadow: 0 0 12px rgba(73, 245, 162, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5); }

@keyframes markFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.logo {
  margin: 0;
  position: relative;
  z-index: 1;
  font-family: var(--sans);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(32px, 10vw, 42px);
  line-height: 0.94;
  letter-spacing: 0.045em;
  transform: skewX(-4deg);
}

.logo span { display: block; }

.logo-a {
  color: #FFFFFF;
  text-shadow:
    0 0 10px rgba(34, 232, 255, 0.75),
    0 0 34px rgba(34, 232, 255, 0.4),
    2px 0 0 rgba(255, 63, 203, 0.55);
}

.logo-b {
  color: var(--orange);
  text-shadow:
    0 0 12px rgba(255, 138, 61, 0.85),
    0 0 38px rgba(255, 106, 18, 0.45),
    -2px 0 0 rgba(34, 232, 255, 0.45);
}

.logo-cn {
  margin: 10px 0 0;
  position: relative;
  z-index: 1;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.boot-best {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 18px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 138, 61, 0.3);
  background: rgba(255, 138, 61, 0.08);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: rgba(255, 170, 110, 0.85);
  position: relative;
  z-index: 1;
}

.boot-best b {
  font-size: 15px;
  color: var(--orange);
  text-shadow: 0 0 12px rgba(255, 138, 61, 0.6);
}

.boot-hint {
  margin: 14px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--dim);
  position: relative;
  z-index: 1;
}

/* shared card bits */

.card-kicker {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--cyan);
  opacity: 0.75;
  position: relative;
  z-index: 1;
}

.card-title {
  margin: 10px 0 0;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 0.04em;
  position: relative;
  z-index: 1;
  text-shadow: 0 0 22px rgba(255, 138, 61, 0.3);
}

.over-title { color: var(--orange); text-shadow: 0 0 26px rgba(255, 138, 61, 0.55); }

.card-sub {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.05em;
  position: relative;
  z-index: 1;
}

.result {
  margin: 18px 0 4px;
  border-radius: 14px;
  border: 1px solid rgba(34, 232, 255, 0.14);
  background: rgba(4, 6, 16, 0.55);
  padding: 6px 14px;
  position: relative;
  z-index: 1;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.result-row + .result-row { border-top: 1px dashed rgba(124, 134, 168, 0.18); }

.result-row b {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.result-row b.gold { color: var(--orange); text-shadow: 0 0 12px rgba(255, 138, 61, 0.5); }

/* buttons */

.btn-primary {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 54px;
  margin-top: 18px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(180deg, #FFA868, #FF7A16 62%, #F06300);
  color: #200C00;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow:
    0 10px 28px rgba(255, 106, 18, 0.35),
    0 0 0 1px rgba(255, 200, 160, 0.45) inset,
    0 1px 0 rgba(255, 255, 255, 0.45) inset;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-primary .mp-icon { width: 22px; height: 22px; color: #200C00; }

.btn-primary:active {
  transform: translateY(1px) scale(0.985);
  filter: brightness(1.06);
  box-shadow: 0 5px 16px rgba(255, 106, 18, 0.3), 0 0 0 1px rgba(255, 200, 160, 0.4) inset;
}

.btn-ghost {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 46px;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(34, 232, 255, 0.28);
  background: rgba(34, 232, 255, 0.05);
  color: #BFD2FF;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn-ghost .mp-icon { width: 18px; height: 18px; }
.btn-ghost:active { transform: scale(0.98); background: rgba(34, 232, 255, 0.12); border-color: rgba(34, 232, 255, 0.5); }

/* short screens */

@media (max-height: 620px) {
  .hud { padding-top: 5px; }
  .tray { padding-top: 5px; }
  .tray-card { height: 48px; }
  .cv-wrap { height: 38px; }
  .arena { padding-top: 5px; padding-bottom: 5px; }
  .pad { padding-top: 6px; padding-bottom: calc(7px + env(safe-area-inset-bottom, 0px)); }
  .key { height: 52px; }
  .key .mp-icon { width: 21px; height: 21px; }
  .card { padding: 20px 18px 18px; }
  .logo { font-size: 30px; }
  .logo-mark { margin-bottom: 12px; }
  .boot-best { margin-top: 12px; }
  .btn-primary { margin-top: 14px; }
}
