:root {
  --ink: #0b2033;
  --navy: #0a233a;
  --navy-2: #102f4e;
  --sea: #168bc5;
  --blue: #1665d8;
  --blue-2: #39a7ff;
  --ice: #9fe6ff;
  --gold: #f5bd3a;
  --gold-2: #ffe19a;
  --bronze: #8b5a25;
  --sand: #eac78f;
  --paper: #fff0c7;
  --paper-2: #e5bd7c;
  --red: #d53c35;
  --white: #fff8e7;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--navy); }
body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--white);
  font-family: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  background: var(--navy);
}
button, input, canvas { -webkit-tap-highlight-color: transparent; }
button, input { font-family: inherit; }

.shell {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(5,22,37,.72) 0%, rgba(5,22,37,.16) 30%, rgba(5,22,37,.12) 66%, rgba(5,22,37,.68) 100%),
    linear-gradient(180deg, rgba(3,18,31,.05), rgba(3,18,31,.62)),
    url("assets/site-background.webp") center center / cover fixed no-repeat;
}
.shell::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  box-shadow: inset 0 0 180px rgba(3,15,26,.48);
}

.game-card {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 430 / 760;
  overflow: hidden;
  border: 3px solid #e3b65b;
  border-radius: 24px;
  background: linear-gradient(180deg,#8ed8ff 0%,#51b4e6 38%,#227dad 100%);
  box-shadow:
    0 30px 95px rgba(0,0,0,.58),
    0 0 0 2px rgba(25,57,79,.95),
    0 0 0 5px rgba(255,214,116,.16),
    inset 0 0 0 1px rgba(255,255,255,.25);
}
.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  border-radius: 20px;
  box-shadow: inset 0 0 28px rgba(6,25,40,.22);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

.hud-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.brand-chip {
  position: absolute;
  left: 11px;
  bottom: 9px;
  padding: 5px 9px 4px;
  border: 1px solid rgba(255,218,128,.42);
  border-radius: 999px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: 8px;
  letter-spacing: .12em;
  color: rgba(255,247,222,.84);
  background: rgba(7,25,39,.64);
  box-shadow: 0 3px 10px rgba(0,0,0,.16);
  backdrop-filter: blur(7px);
}

.screen-panel {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 18%, rgba(57,167,255,.15), transparent 28%),
    linear-gradient(rgba(4,20,34,.28), rgba(4,20,34,.78));
  backdrop-filter: blur(2.5px) saturate(1.05);
}
.screen-panel.active { display: flex; }

.panel-box {
  position: relative;
  width: 100%;
  padding: 26px 22px 22px;
  overflow: hidden;
  border: 2px solid #83571f;
  border-radius: 20px;
  color: var(--ink);
  text-align: center;
  background:
    radial-gradient(circle at 50% -10%, rgba(255,255,255,.74), transparent 34%),
    linear-gradient(180deg, #fff4d1 0%, #f3d69e 45%, #dcae69 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255,223,144,.88),
    inset 0 -10px 30px rgba(137,88,32,.10),
    0 20px 55px rgba(1,12,21,.46);
}
.panel-box::before,
.panel-box::after {
  content: "";
  position: absolute;
  top: 0;
  width: 58px;
  height: 5px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .95;
}
.panel-box::before { left: 18px; }
.panel-box::after { right: 18px; }
.panel-box.compact { max-width: 340px; }

.start-box {
  max-height: calc(100% - 8px);
  padding-top: 18px;
  overflow-y: auto;
  scrollbar-width: none;
}
.start-box::-webkit-scrollbar { display: none; }
.game-logo {
  display: block;
  width: min(100%, 330px);
  height: auto;
  margin: -4px auto 0;
  filter: drop-shadow(0 10px 14px rgba(44,27,10,.28));
}
.start-copy {
  margin: -2px auto 14px !important;
  max-width: 330px;
  color: #223546 !important;
  font-size: 15px !important;
  font-weight: 650;
  line-height: 1.24 !important;
}

.eyebrow {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
  color: #79511f;
  text-transform: uppercase;
}
h1, h2, .primary-btn, .secondary-btn, .icon-btn, .nickname-input,
.final-stats strong, .ranking-score, .ranking-position {
  font-family: "Lilita One", Impact, "Arial Black", sans-serif;
}
h2 {
  margin: 4px 0 16px;
  color: #11385c;
  font-size: 36px;
  font-weight: 400;
  letter-spacing: .005em;
  text-shadow: 0 2px 0 rgba(255,255,255,.48);
}
.panel-box p { color: #263d4d; }

.nickname-label {
  display: block;
  margin: 2px 0 6px;
  color: #76501f;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.nickname-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 2px solid #9f7131;
  border-radius: 12px;
  outline: none;
  background: rgba(255,252,239,.92);
  color: #123b60;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: .025em;
  text-align: center;
  box-shadow: inset 0 3px 7px rgba(82,49,13,.12), 0 1px 0 rgba(255,255,255,.72);
}
.nickname-input::placeholder { color: #73808a; opacity: .74; }
.nickname-input:focus { border-color: #1e72dc; box-shadow: 0 0 0 3px rgba(30,114,220,.18), inset 0 3px 7px rgba(82,49,13,.10); }
.nickname-input.invalid { border-color: #bd4036; box-shadow: 0 0 0 3px rgba(189,64,54,.14); }
.nickname-error { min-height: 16px; margin: 4px 0 1px; color: #9e3029; font-size: 11px; font-weight: 800; }

.controls-hint {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 14px;
}
.controls-hint div {
  padding: 8px 7px;
  border: 1px solid rgba(103,67,27,.18);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.58), rgba(255,255,255,.28));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.56);
}
.controls-hint b,
.controls-hint span { display: block; }
.controls-hint b { color: #144c7f; font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.controls-hint span { margin-top: 2px; color: #465760; font-size: 10px; font-weight: 650; }

.primary-btn,
.secondary-btn,
.icon-btn {
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.primary-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-decoration: none;
  min-height: 52px;
  border: 2px solid #f2cc72;
  border-bottom: 5px solid #082e68;
  border-radius: 13px;
  color: white;
  background: linear-gradient(180deg, #49a9ff 0%, #1e73e0 48%, #1555b7 100%);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: .035em;
  text-shadow: 0 2px 0 rgba(6,42,91,.78);
  box-shadow: 0 7px 0 rgba(75,48,17,.12), inset 0 2px 0 rgba(255,255,255,.27);
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: translateY(3px); border-bottom-width: 2px; box-shadow: 0 3px 0 rgba(75,48,17,.12); }
.secondary-btn {
  width: 100%;
  min-height: 42px;
  margin-top: 9px;
  border: 2px solid #916225;
  border-bottom: 4px solid #73471b;
  border-radius: 11px;
  color: #513719;
  background: linear-gradient(180deg, #fff3c8 0%, #e9c27e 100%);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: .045em;
  text-shadow: 0 1px 0 rgba(255,255,255,.58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}
.secondary-btn:hover { filter: brightness(1.04); }
.secondary-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.panel-box small {
  display: block;
  margin-top: 10px;
  color: #5c4934;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
}

.end-box::after {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin: 15px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #b37b27, transparent);
}
.player-result-name {
  margin: -8px 0 12px;
  color: #93601d;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 18px;
}
.final-stats div {
  padding: 12px;
  border: 1px solid rgba(122,77,25,.16);
  border-radius: 12px;
  background: rgba(255,255,255,.48);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.58);
}
.final-stats span,
.final-stats strong { display: block; }
.final-stats span { color: #725c3f; font-size: 10px; font-weight: 900; letter-spacing: .10em; text-transform: uppercase; }
.final-stats strong { margin-top: 2px; color: #123b60; font-size: 27px; font-weight: 400; }
.ranking-submit-status {
  min-height: 34px;
  margin: -6px 0 12px;
  padding: 8px 10px;
  border-radius: 9px;
  color: #534938;
  background: rgba(255,255,255,.42);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
}
.ranking-submit-status.success { color: #285c37; background: rgba(196,237,200,.62); }
.ranking-submit-status.error { color: #8c322d; background: rgba(255,212,202,.60); }

.ranking-screen { padding: 14px; }
.ranking-box {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: min(690px, calc(100dvh - 28px));
  max-height: 92%;
  padding: 20px 16px 14px;
  overflow: hidden;
}
.ranking-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ranking-header h2 { margin: 2px 0 8px; font-size: 34px; text-align: left; }
.icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 2px solid #916225;
  border-radius: 10px;
  color: #153f64;
  background: linear-gradient(#fff0c5, #e4bc78);
  font-size: 28px;
  line-height: 30px;
  font-weight: 400;
}
.ranking-message { min-height: 21px; margin-bottom: 6px; color: #3d4a4d; font-size: 11px; font-weight: 800; text-align: left; }
.ranking-table-head,
.ranking-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 8px;
}
.ranking-table-head {
  padding: 7px 9px;
  border: 1px solid rgba(116,76,29,.12);
  border-radius: 8px;
  color: #68461f;
  background: rgba(114,73,27,.12);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.ranking-table-head span:last-child { text-align: right; }
.ranking-list {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #a97631 transparent;
}
.ranking-row {
  min-height: 41px;
  padding: 5px 9px;
  border-bottom: 1px solid rgba(76,57,36,.12);
  color: #263a45;
  font-size: 13px;
}
.ranking-row.me { border-radius: 8px; background: linear-gradient(90deg, rgba(44,127,226,.18), rgba(44,127,226,.06)); }
.ranking-position { color: #9a6825; font-size: 15px; font-weight: 400; }
.ranking-nickname { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 800; text-align: left; }
.ranking-score { color: #123b60; font-size: 15px; font-weight: 400; text-align: right; font-variant-numeric: tabular-nums; }
.ranking-refresh { flex: 0 0 auto; margin-top: 8px; }
.ranking-empty { padding: 28px 12px; color: #6d5d49; font-size: 13px; font-weight: 700; line-height: 1.45; text-align: center; }

.desktop-note {
  display: none;
}
.desktop-logo {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 13px 18px rgba(0,0,0,.36));
}
.feature-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.feature-tags span {
  padding: 6px 9px;
  border: 1px solid rgba(255,220,139,.30);
  border-radius: 999px;
  color: #fff3d2;
  background: rgba(7,32,52,.66);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .035em;
  backdrop-filter: blur(5px);
}
.akilli-signature {
  margin-top: 4px;
  color: rgba(255,255,255,.68);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .11em;
}
.akilli-signature strong { color: #ffd77b; }

@media (min-width: 900px) {
  .shell { grid-template-columns: auto 330px; gap: clamp(38px, 5vw, 72px); }
  .desktop-note {
    display: grid;
    gap: 14px;
    width: 330px;
    padding: 22px;
    border: 1px solid rgba(255,219,133,.22);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(6,28,47,.72), rgba(6,25,42,.50));
    box-shadow: 0 24px 70px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.08);
    backdrop-filter: blur(14px) saturate(1.15);
  }
  .desktop-note p {
    margin: -2px 0 0;
    color: #e6f2f7;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    text-shadow: 0 1px 8px rgba(0,0,0,.28);
  }
}

@media (max-width: 470px) {
  .shell {
    display: block;
    padding: 0;
    background:
      linear-gradient(rgba(3,18,30,.12), rgba(3,18,30,.42)),
      url("assets/site-background.webp") center center / cover fixed no-repeat;
  }
  .game-card {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .game-card::before { border-radius: 0; }
  .screen-panel { padding: 12px; }
  .start-box { max-height: calc(100dvh - 24px); }
  .game-logo { width: min(93%, 325px); }
}

@media (max-height: 700px) {
  .screen-panel { padding: 9px 13px; }
  .start-box { padding: 13px 18px 14px; }
  .start-box .eyebrow { font-size: 9px; }
  .game-logo { width: min(82%, 280px); margin-top: -8px; }
  .start-copy { margin: -6px auto 8px !important; font-size: 13px !important; }
  .nickname-input { height: 42px; font-size: 18px; }
  .nickname-error { min-height: 13px; font-size: 9px; }
  .controls-hint { margin: 5px 0 8px; }
  .controls-hint div { padding: 5px 6px; }
  .primary-btn { min-height: 45px; font-size: 20px; }
  .secondary-btn { min-height: 36px; margin-top: 6px; }
  .panel-box small { margin-top: 6px; font-size: 9px; }
  .ranking-box { height: calc(100dvh - 18px); max-height: none; }
}
