:root {
  --bg: #070a0b;
  --panel: #101512;
  --panel-2: #151d18;
  --panel-3: #1b261f;
  --text: #f4fff4;
  --muted: #afc4b6;
  --soft: #8fa699;
  --line: #31483d;
  --line-strong: #49685a;
  --accent: #74f2a1;
  --accent-dim: #2f8f60;
  --gold: #f8c85e;
  --cyan: #65d8ff;
  --danger: #ff6b7a;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.48);
  --glow: 0 0 34px rgba(116, 242, 161, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(11, 36, 30, 0.55), transparent 42%),
    linear-gradient(120deg, transparent 56%, rgba(36, 25, 11, 0.38)),
    repeating-linear-gradient(0deg, rgba(116, 242, 161, 0.035) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(90deg, rgba(101, 216, 255, 0.025) 0 1px, transparent 1px 112px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid rgba(116, 242, 161, 0.34);
  border-radius: 12px;
  background: linear-gradient(180deg, #202d26, #162119);
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  padding: 0 18px;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.24);
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

button:hover,
button:focus-visible {
  border-color: rgba(116, 242, 161, 0.9);
  background: linear-gradient(180deg, #25382d, #18281f);
  box-shadow: 0 0 24px rgba(116, 242, 161, 0.18);
  outline: none;
}

button:active {
  transform: translateY(1px);
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 500px;
  gap: 14px;
  width: min(1880px, calc(100vw - 14px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 8px 0;
  align-items: stretch;
}

.play-section,
.side-panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(73, 104, 90, 0.85);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(23, 32, 27, 0.88), rgba(12, 18, 15, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
}

.play-section::before,
.side-panel::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(116, 242, 161, 0.1);
  border-radius: 14px;
  pointer-events: none;
}

.play-section {
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.play-area {
  display: grid;
  flex: 1;
  min-height: 0;
  gap: 14px;
  align-items: end;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.5rem, 3.25vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.dorak-back {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-decoration: none;
}

.dorak-back:hover,
.dorak-back:focus-visible {
  color: var(--accent);
  outline: none;
}

h2 {
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-top: 24px;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.side-panel p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.stat {
  border: 1px solid rgba(73, 104, 90, 0.7);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(31, 44, 36, 0.92), rgba(16, 23, 19, 0.96));
  padding: 10px 12px;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.28);
}

.stat:first-child {
  border-color: rgba(116, 242, 161, 0.68);
  box-shadow: 0 0 28px rgba(116, 242, 161, 0.14);
}

.stat span,
.meters span {
  display: block;
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.65rem;
  line-height: 1;
}

.stat:last-child strong {
  color: var(--gold);
}

.game-frame {
  position: relative;
  justify-self: start;
  overflow: hidden;
  width: min(100%, 790px);
  margin: 0;
  border: 1px solid rgba(73, 104, 90, 0.95);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(7, 16, 13, 0.94), rgba(5, 11, 9, 0.98)),
    #07100d;
  aspect-ratio: 1;
  box-shadow:
    inset 0 0 0 8px rgba(116, 242, 161, 0.025),
    0 0 42px rgba(116, 242, 161, 0.18),
    0 28px 58px rgba(0, 0, 0, 0.42);
}

@supports (min-height: 100dvh) {
  .game-shell {
    min-height: 100dvh;
  }
}

@media (min-width: 1121px) {
  .game-shell {
    height: 100svh;
  }

  .game-frame {
    width: min(100%, 790px, calc(100svh - 116px));
  }

  @supports (height: 100dvh) {
    .game-shell {
      height: 100dvh;
    }

    .game-frame {
      width: min(100%, 790px, calc(100dvh - 116px));
    }
  }
}

.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 16%, transparent 82%, rgba(116, 242, 161, 0.035));
  pointer-events: none;
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 10, 11, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-panel {
  width: min(330px, 100%);
  border: 1px solid rgba(116, 242, 161, 0.24);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(23, 32, 27, 0.94), rgba(12, 18, 15, 0.96));
  padding: 24px;
  text-align: center;
  box-shadow:
    0 0 40px rgba(116, 242, 161, 0.12),
    0 22px 58px rgba(0, 0, 0, 0.48);
}

.overlay-panel h2 {
  font-size: 1.9rem;
}

.overlay-panel p {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

#startButton {
  min-width: 132px;
  background: linear-gradient(180deg, #8affaa, #62dd83);
  color: #07140d;
  border-color: transparent;
  box-shadow: 0 0 28px rgba(116, 242, 161, 0.28);
}

.side-panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  padding: 22px;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  gap: 7px;
  justify-content: center;
  margin-top: 14px;
}

kbd,
.touch-btn {
  display: grid;
  place-items: center;
  min-width: 0;
  width: 50px;
  height: 48px;
  border: 1px solid rgba(73, 104, 90, 0.78);
  border-radius: 12px;
  background: #151b1a;
  color: #d8e8dc;
  font-size: 0.95rem;
  font-weight: 900;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.24);
}

.primary-key {
  border-color: rgba(116, 242, 161, 0.8);
  background: #18382f;
  color: #e9fff0;
  box-shadow: 0 0 22px rgba(116, 242, 161, 0.24);
}

.touch-pad {
  display: none;
  margin-top: 20px;
}

.touch-btn {
  padding: 0;
  border: 1px solid rgba(167, 171, 200, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--cyan);
  font-size: 1.5rem;
  font-weight: 900;
  box-shadow: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.touch-btn:hover,
.touch-btn:focus-visible {
  border-color: rgba(101, 216, 255, 0.52);
  background: rgba(101, 216, 255, 0.11);
  color: var(--cyan);
  box-shadow: none;
}

.touch-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.touch-btn:active {
  transform: scale(0.96);
}

.meters {
  display: grid;
  gap: 16px;
  margin-top: auto;
  padding-top: 20px;
}

.meter {
  overflow: hidden;
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: #07100d;
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  box-shadow: 0 0 18px rgba(116, 242, 161, 0.32);
  transition: width 140ms ease;
}

.meters > div:last-child .meter i {
  background: linear-gradient(90deg, var(--gold), #ffe69a);
  box-shadow: 0 0 18px rgba(248, 200, 94, 0.28);
}

@media (max-width: 1120px) {
  .game-shell {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 20px 0;
  }

  .side-panel {
    max-width: none;
  }
}

@media (max-height: 920px) and (min-width: 1121px) {
  .game-shell {
    width: min(1880px, calc(100vw - 14px));
    grid-template-columns: minmax(0, 1fr) 500px;
    gap: 14px;
    padding: 4px 0;
  }

  .play-section {
    padding: 10px;
  }

  .side-panel {
    padding: 18px;
  }

  .play-area {
    gap: 10px;
  }

  h1 {
    font-size: 2.35rem;
  }

  .side-panel p {
    margin-top: 5px;
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .game-frame {
    width: min(100%, 790px, calc(100svh - 92px));
  }

  @supports (height: 100dvh) {
    .game-frame {
      width: min(100%, 790px, calc(100dvh - 92px));
    }
  }

  .stat {
    padding: 7px 9px;
  }

  .stat strong {
    font-size: 1.25rem;
  }

  button {
    min-height: 38px;
  }

  button {
    border-radius: 10px;
    padding: 0 14px;
    font-size: 0.82rem;
  }

  .overlay-panel {
    width: min(280px, 100%);
    padding: 18px;
  }

  .overlay-panel h2 {
    font-size: 1.5rem;
  }

  h3 {
    margin-top: 14px;
    font-size: 0.9rem;
  }

  .key-grid {
    grid-template-columns: repeat(3, 42px);
    gap: 6px;
    margin-top: 10px;
  }

  kbd,
  .touch-btn {
    width: 42px;
    height: 40px;
    border-radius: 10px;
  }

  .meters {
    gap: 12px;
    padding-top: 12px;
  }

}

@media (max-width: 780px) {
  .game-shell {
    width: min(100vw - 12px, 620px);
    gap: 8px;
    padding: 6px 0;
  }

  .play-section {
    border-radius: 14px;
    padding: 8px;
  }

  .side-panel {
    display: none;
  }

  .play-area {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .game-frame {
    order: 1;
  }

  h1 {
    font-size: 1.8rem;
  }

  .dorak-back {
    margin-bottom: 4px;
  }

  .stat {
    padding: 8px;
    border-radius: 12px;
  }

  .stat strong {
    font-size: 1.25rem;
  }

  .game-frame {
    border-radius: 14px;
  }

  .side-panel h2 {
    font-size: 1.45rem;
  }
}

@media (max-width: 780px) {
  .play-area > .touch-pad {
    position: relative;
    order: 2;
    display: block;
    width: 150px;
    height: 114px;
    margin: 0 auto;
  }

  .touch-pad::after {
    content: "";
    position: absolute;
    top: 52px;
    left: 70px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4fd8;
    box-shadow: 0 0 16px rgba(255, 79, 216, 0.5);
    pointer-events: none;
  }

  .touch-btn {
    position: absolute;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    border-radius: 16px;
  }

  .touch-btn.up {
    top: 0;
    left: 51px;
  }

  .touch-btn.left {
    top: 33px;
    left: 0;
  }

  .touch-btn.right {
    top: 33px;
    right: 0;
  }

  .touch-btn.down {
    bottom: 0;
    left: 51px;
  }
}

/* Photo Chase-aligned game chrome */
.game-header {
  min-height: 2.6rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.15rem 0.25rem 0.55rem;
}

.game-header .dorak-back {
  margin: 0;
}

.brand {
  min-width: 0;
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  color: var(--text);
  font-family: "Arial Black", ui-rounded, sans-serif;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 1.75rem;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border: 0.3rem solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  filter: drop-shadow(0 0 0.7rem rgba(116, 242, 161, 0.4));
  transform: rotate(12deg);
}

.brand-mark i {
  position: absolute;
  top: 0.22rem;
  left: 0.48rem;
  width: 0.23rem;
  aspect-ratio: 1;
  background: #07100d;
  border-radius: 50%;
}

.status-chip {
  padding: 0.4rem 0.65rem;
  color: var(--accent);
  background: rgba(116, 242, 161, 0.07);
  border: 1px solid rgba(116, 242, 161, 0.28);
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 1000;
  letter-spacing: 0.09em;
  white-space: nowrap;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(4rem, 1fr)) auto;
  align-items: center;
  min-height: 4rem;
  margin-bottom: 0.55rem;
  overflow: hidden;
  background: linear-gradient(115deg, rgba(24, 38, 30, 0.94), rgba(11, 20, 15, 0.88));
  border: 1px solid rgba(116, 242, 161, 0.18);
  border-radius: 1.1rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.scoreboard .stat {
  min-width: 0;
  padding: 0.68rem clamp(0.65rem, 3vw, 1.3rem);
  display: grid;
  gap: 0.18rem;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(143, 166, 153, 0.12);
  border-radius: 0;
  box-shadow: none;
}

.scoreboard .stat:first-child {
  border-color: rgba(143, 166, 153, 0.12);
  box-shadow: none;
}

.scoreboard .stat-label {
  color: var(--soft);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.scoreboard .stat strong {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Arial Black", ui-rounded, sans-serif;
  font-size: clamp(1rem, 4.2vw, 1.45rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
}

.scoreboard .stat-score strong {
  color: var(--gold);
}

.hud-actions {
  padding: 0.45rem;
  display: flex;
  gap: 0.35rem;
}

.icon-button {
  width: 2.8rem;
  min-width: 2.8rem;
  height: 2.8rem;
  min-height: 2.8rem;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(143, 166, 153, 0.22);
  border-radius: 0.85rem;
  box-shadow: none;
  font-size: 1.15rem;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--cyan);
  background: rgba(101, 216, 255, 0.11);
  border-color: rgba(101, 216, 255, 0.52);
  box-shadow: none;
}

.icon-button:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.icon-button.is-active {
  color: #ff4fd8;
  border-color: rgba(255, 79, 216, 0.44);
}

.icon-button:active {
  transform: scale(0.96);
}

.play-area {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: center;
  gap: 0.55rem;
}

.game-frame {
  justify-self: center;
}

.overlay {
  z-index: 3;
  background:
    radial-gradient(circle at 50% 40%, rgba(28, 69, 49, 0.56), rgba(7, 12, 9, 0.92) 68%),
    linear-gradient(rgba(7, 12, 9, 0.34), rgba(7, 12, 9, 0.84));
  backdrop-filter: blur(4px);
}

.overlay-panel {
  width: min(100%, 31rem);
  display: grid;
  justify-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.overlay-panel [hidden] {
  display: none !important;
}

#overlayMain,
.nickname-setup {
  width: 100%;
  display: grid;
  justify-items: center;
}

.eyebrow {
  color: #ff4fd8;
  font-size: 0.64rem;
  font-weight: 1000;
  letter-spacing: 0.13em;
}

.overlay-panel h1,
.nickname-setup h2 {
  margin: 0.65rem 0 0;
  color: var(--text);
  font-family: "Arial Black", ui-rounded, sans-serif;
  font-size: clamp(1.65rem, 6vw, 3.25rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.overlay-panel p,
.nickname-setup p {
  max-width: 33rem;
  margin: 0.9rem 0 0;
  color: #c8d9cd;
  font-size: clamp(0.78rem, 2.4vw, 1rem);
  line-height: 1.5;
  text-wrap: balance;
}

.overlay-actions {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.primary-button,
.secondary-button,
.dialog-button,
.leaderboard-tab {
  min-height: 2.8rem;
  padding: 0 1rem;
  border-radius: 0.8rem;
  font-size: 0.72rem;
  font-weight: 1000;
  letter-spacing: 0.055em;
}

.primary-button {
  color: #07140d;
  background: linear-gradient(135deg, #a6ffba, #62dd83);
  border-color: transparent;
  box-shadow: 0 0.7rem 2rem rgba(116, 242, 161, 0.2);
}

.primary-button b {
  margin-left: 0.55rem;
}

.secondary-button,
.dialog-button,
.leaderboard-tab {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(143, 166, 153, 0.28);
  box-shadow: none;
}

#viewLeaderboardButton {
  margin-top: 0.7rem;
}

.pause-setting {
  width: min(100%, 24rem);
  min-height: 4.2rem;
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  background: rgba(116, 242, 161, 0.06);
  border: 1px solid rgba(116, 242, 161, 0.22);
  border-radius: 0.9rem;
}

.pause-setting span {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.pause-setting strong {
  font-size: 0.78rem;
}

.pause-setting small {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.35;
}

.pause-setting input {
  position: relative;
  width: 2.8rem;
  height: 1.5rem;
  flex: 0 0 auto;
  appearance: none;
  cursor: pointer;
  background: #07100d;
  border: 1px solid rgba(143, 166, 153, 0.5);
  border-radius: 999px;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.pause-setting input::before {
  position: absolute;
  top: 0.18rem;
  left: 0.2rem;
  width: 1rem;
  height: 1rem;
  content: "";
  background: var(--muted);
  border-radius: 50%;
  transition: transform 150ms ease, background-color 150ms ease;
}

.pause-setting input:checked {
  background: rgba(116, 242, 161, 0.22);
  border-color: var(--accent);
}

.pause-setting input:checked::before {
  background: var(--accent);
  transform: translateX(1.2rem);
}

.pause-setting input:focus-visible {
  outline: 3px solid rgba(101, 216, 255, 0.34);
  outline-offset: 3px;
}

.submission-status {
  color: var(--gold) !important;
  font-size: 0.72rem !important;
  font-weight: 900;
}

.nickname-setup form {
  width: min(100%, 22rem);
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
  text-align: left;
}

.nickname-setup form > label {
  font-size: 0.68rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nickname-setup input {
  width: 100%;
  min-height: 3rem;
  padding: 0 0.85rem;
  color: var(--text);
  background: rgba(4, 12, 8, 0.78);
  border: 1px solid rgba(143, 166, 153, 0.36);
  border-radius: 0.8rem;
  outline: 0;
}

.nickname-setup input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(101, 216, 255, 0.13);
}

.nickname-setup input[aria-invalid="true"] {
  border-color: var(--danger);
}

.nickname-setup .nickname-rules,
.nickname-setup .nickname-error {
  margin: 0;
  font-size: 0.68rem;
  text-align: left;
}

.nickname-setup .nickname-error {
  color: #ff8b9c;
  font-weight: 900;
}

.nickname-setup .primary-button {
  margin: 0.35rem auto 0;
}

.leaderboard-dialog {
  width: min(52rem, calc(100% - 2rem));
  max-width: none;
  height: min(44rem, calc(100dvh - 2rem));
  max-height: none;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: #08110d;
  border: 1px solid rgba(101, 216, 255, 0.35);
  border-radius: 1.3rem;
  box-shadow: 0 2rem 8rem rgba(0, 0, 0, 0.75), 0 0 3rem rgba(101, 216, 255, 0.1);
}

.leaderboard-dialog::backdrop {
  background: rgba(3, 8, 6, 0.84);
  backdrop-filter: blur(7px);
}

.leaderboard-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 15% -15%, rgba(101, 216, 255, 0.14), transparent 19rem),
    linear-gradient(155deg, rgba(20, 36, 27, 0.98), rgba(6, 14, 10, 0.99));
}

.leaderboard-header {
  padding: 1.15rem 1.3rem 0.9rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  background: rgba(8, 18, 13, 0.94);
  border-bottom: 1px solid rgba(143, 166, 153, 0.14);
}

.leaderboard-header h2 {
  margin: 0.3rem 0 0;
  font-family: "Arial Black", ui-rounded, sans-serif;
  font-size: clamp(1.35rem, 4vw, 2.2rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

#leaderboardStatus {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

#leaderboardStatus.is-stale {
  color: var(--gold);
}

.leaderboard-tabs {
  padding: 0.65rem 1.25rem;
  display: flex;
  gap: 0.55rem;
  background: rgba(8, 18, 13, 0.9);
  border-bottom: 1px solid rgba(143, 166, 153, 0.12);
}

.leaderboard-tab {
  min-height: 2.4rem;
}

.leaderboard-tab.is-active {
  color: #07140d;
  background: var(--accent);
  border-color: var(--accent);
}

.leaderboard-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.leaderboard-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.leaderboard-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #102019;
  box-shadow: 0 1px rgba(143, 166, 153, 0.18);
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.85rem 0.8rem;
  text-align: left;
}

.leaderboard-table thead th {
  font-size: 0.62rem;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.leaderboard-row {
  border-bottom: 1px solid rgba(143, 166, 153, 0.1);
}

.leaderboard-row.is-current {
  background: linear-gradient(90deg, rgba(101, 216, 255, 0.14), rgba(255, 79, 216, 0.08));
  box-shadow: 3px 0 var(--cyan) inset;
}

.leaderboard-rank,
.leaderboard-score,
.leaderboard-progress {
  font-family: "Arial Black", ui-rounded, sans-serif;
}

.leaderboard-rank {
  width: 4.5rem;
  color: var(--gold);
}

.leaderboard-name {
  max-width: 16rem;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: var(--cyan);
}

.leaderboard-progress {
  color: #c6a9ff;
  font-size: 0.74rem;
}

.leaderboard-date {
  color: var(--muted);
  font-size: 0.77rem;
}

.leaderboard-empty {
  max-width: 28rem;
  margin: 4rem auto;
  padding: 0 1.5rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.leaderboard-footer {
  padding: 0.85rem 1.25rem max(0.85rem, env(safe-area-inset-bottom));
  display: flex;
  gap: 0.7rem;
  justify-content: space-between;
  background: rgba(8, 18, 13, 0.96);
  border-top: 1px solid rgba(143, 166, 153, 0.14);
}

.dialog-button:disabled {
  opacity: 0.42;
  cursor: wait;
}

.dialog-button-accent {
  color: var(--gold);
  border-color: rgba(248, 200, 94, 0.34);
}

@media (min-width: 1121px) {
  .game-frame {
    width: min(100%, 790px, calc(100svh - 142px));
  }

  @supports (height: 100dvh) {
    .game-frame {
      width: min(100%, 790px, calc(100dvh - 142px));
    }
  }
}

@media (max-height: 920px) and (min-width: 1121px) {
  .game-frame {
    width: min(100%, 790px, calc(100svh - 122px));
  }

  @supports (height: 100dvh) {
    .game-frame {
      width: min(100%, 790px, calc(100dvh - 122px));
    }
  }
}

@media (max-width: 780px) {
  .game-header {
    min-height: 2.2rem;
    gap: 0.45rem;
    padding: 0 0.1rem 0.35rem;
  }

  .brand {
    gap: 0.35rem;
    font-size: 0.7rem;
  }

  .brand-mark {
    width: 1.45rem;
  }

  .status-chip {
    padding: 0.34rem 0.5rem;
    font-size: 0.49rem;
  }

  .scoreboard {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    min-height: 3.35rem;
    margin-bottom: 0.35rem;
    border-radius: 0.85rem;
  }

  .scoreboard .stat {
    padding: 0.5rem 0.3rem;
  }

  .scoreboard .stat-label {
    font-size: 0.5rem;
    letter-spacing: 0.04em;
  }

  .scoreboard .stat strong {
    font-size: clamp(0.85rem, 4.2vw, 1.1rem);
  }

  .hud-actions {
    padding: 0.2rem;
    gap: 0.12rem;
  }

  .icon-button {
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.75rem;
    min-height: 2.75rem;
    border-radius: 0.7rem;
  }

  .overlay-panel {
    width: min(100%, 27rem);
  }

  .overlay-panel h1,
  .nickname-setup h2 {
    margin-top: 0.45rem;
  }

  .overlay-panel p,
  .nickname-setup p {
    margin-top: 0.6rem;
    line-height: 1.35;
  }

  .overlay-actions {
    margin-top: 0.75rem;
  }

  .pause-setting {
    min-height: 3.6rem;
    margin-top: 0.7rem;
    padding: 0.55rem 0.7rem;
  }

  .leaderboard-dialog {
    width: calc(100% - 0.7rem);
    height: calc(100dvh - max(0.7rem, env(safe-area-inset-top)) - max(0.7rem, env(safe-area-inset-bottom)));
    border-radius: 1rem;
  }

  .leaderboard-header {
    padding: max(0.9rem, env(safe-area-inset-top)) 0.8rem 0.7rem;
    gap: 0.55rem;
  }

  .leaderboard-header h2 {
    font-size: clamp(1.2rem, 6vw, 1.65rem);
  }

  .leaderboard-tabs {
    padding: 0.55rem 0.7rem;
  }

  .leaderboard-table,
  .leaderboard-table thead,
  .leaderboard-table tbody {
    display: block;
  }

  .leaderboard-table thead tr,
  .leaderboard-row {
    display: grid;
    grid-template-columns: 2.7rem minmax(0, 1fr) 4.2rem 4.7rem 3.4rem;
    align-items: center;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    min-width: 0;
    padding: 0.72rem 0.28rem;
    overflow: hidden;
    font-size: 0.64rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .leaderboard-table thead th {
    font-size: 0.5rem;
    letter-spacing: 0.04em;
  }

  .leaderboard-footer {
    padding-inline: 0.65rem;
  }

  .leaderboard-footer .dialog-button {
    padding-inline: 0.7rem;
    font-size: 0.62rem;
  }
}

@media (max-width: 370px) {
  .brand span:last-child {
    display: none;
  }

  .scoreboard .stat-label {
    font-size: 0.44rem;
  }

  .icon-button {
    width: 2.65rem;
    min-width: 2.65rem;
    height: 2.65rem;
    min-height: 2.65rem;
  }
}

/* DORAK shell version 1 integration */
.dorak-game-brand {
  position: relative;
  padding-left: 2.15rem;
  font-family: "Arial Black", ui-rounded, sans-serif;
  font-size: .88rem;
}

.dorak-game-brand::before {
  position: absolute;
  left: .15rem;
  width: 1.45rem;
  aspect-ratio: 1;
  content: "";
  border: .27rem solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  filter: drop-shadow(0 0 .7rem rgb(116 242 161 / 40%));
  transform: rotate(12deg);
}

.dorak-status-chip {
  color: var(--accent);
  background: rgb(116 242 161 / 7%);
  border-color: rgb(116 242 161 / 28%);
}

.dorak-hud {
  background: linear-gradient(115deg, rgb(24 38 30 / 94%), rgb(11 20 15 / 88%));
  border-color: rgb(116 242 161 / 18%);
  backdrop-filter: blur(14px);
}

.dorak-stat strong {
  font-family: "Arial Black", ui-rounded, sans-serif;
  letter-spacing: .04em;
}

.dorak-stat.glow-score strong {
  color: var(--gold);
}

.dorak-icon-button {
  color: var(--text);
  background: rgb(255 255 255 / 4%);
  border-color: rgb(143 166 153 / 22%);
  box-shadow: none;
}

.dorak-icon-button:hover,
.dorak-icon-button:focus-visible {
  color: var(--cyan);
  background: rgb(101 216 255 / 11%);
  border-color: rgb(101 216 255 / 52%);
}

.dorak-game-viewport {
  container-type: size;
  background: #07100d;
  border-color: rgb(73 104 90 / 95%);
  box-shadow: inset 0 0 0 8px rgb(116 242 161 / 2.5%), 0 0 42px rgb(116 242 161 / 18%);
}

.dorak-game-content {
  min-width: 0;
  min-height: 0;
  padding: .5rem;
}

.glow-stage {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 15rem);
  gap: .75rem;
}

.glow-board-wrap {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}

.glow-board-wrap .game-frame {
  width: min(100%, 50rem);
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  justify-self: center;
  align-self: center;
  aspect-ratio: 1;
}

@supports (width: 100cqh) {
  .glow-board-wrap .game-frame {
    width: min(100%, 100cqh);
  }
}

.glow-command-rail {
  min-width: 0;
  min-height: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background: linear-gradient(180deg, rgb(23 32 27 / 88%), rgb(12 18 15 / 96%));
  border: 1px solid rgb(73 104 90 / 70%);
  border-radius: var(--dorak-radius-panel);
}

.glow-command-rail h2 {
  font-family: "Arial Black", ui-rounded, sans-serif;
}

.glow-command-rail h3 {
  margin-top: 1rem;
}

.glow-command-rail p {
  margin-top: .45rem;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.4;
}

.glow-command-rail .key-grid {
  grid-template-columns: repeat(3, 44px);
  margin-top: .7rem;
}

.glow-command-rail kbd {
  width: 44px;
  height: 42px;
}

.glow-command-rail .meters {
  margin-top: auto;
}

.glow-control-bay {
  display: none;
}

.touch-pad {
  position: relative;
  width: 150px;
  height: 114px;
  margin: 0;
}

.touch-pad::after {
  position: absolute;
  top: 52px;
  left: 70px;
  width: 10px;
  height: 10px;
  content: "";
  background: #ff4fd8;
  border-radius: 50%;
  box-shadow: 0 0 16px rgb(255 79 216 / 50%);
  pointer-events: none;
}

.touch-pad .touch-btn {
  position: absolute;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 16px;
}

.touch-pad .up {
  top: 0;
  left: 51px;
}

.touch-pad .left {
  top: 33px;
  left: 0;
}

.touch-pad .right {
  top: 33px;
  right: 0;
}

.touch-pad .down {
  bottom: 0;
  left: 51px;
}

.dorak-game-overlay {
  background: radial-gradient(circle at 50% 40%, rgb(28 69 49 / 56%), rgb(7 12 9 / 92%) 68%);
  backdrop-filter: blur(4px);
}

.dorak-overlay-card {
  width: min(100%, 31rem);
  color: var(--text);
  background: linear-gradient(180deg, rgb(23 32 27 / 96%), rgb(12 18 15 / 98%));
  border-color: rgb(116 242 161 / 24%);
}

.dorak-overlay-card h1 {
  font-family: "Arial Black", ui-rounded, sans-serif;
  line-height: .98;
  letter-spacing: -.045em;
}

.dorak-overlay-card .dorak-eyebrow {
  color: #ff4fd8;
}

.glow-overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  justify-content: center;
}

.pause-setting {
  width: min(100%, 24rem);
  min-height: 4rem;
  margin: .9rem auto 0;
}

.submission-status {
  margin: .75rem 0 0 !important;
}

.glow-dialog-body {
  padding: 0;
  overflow: hidden;
}

.leaderboard-content {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.nickname-setup {
  min-height: 100%;
  padding: clamp(1rem, 5vw, 2rem);
  place-content: center;
}

@media (max-width: 900px), (max-height: 700px) {
  .glow-stage {
    grid-template-columns: minmax(0, 1fr);
  }

  .glow-command-rail {
    display: none;
  }
}

@media (max-width: 780px) and (orientation: portrait) {
  .glow-control-bay {
    min-height: 114px;
    display: flex;
  }

  .glow-control-bay .touch-pad {
    display: block;
  }

  .dorak-game-content {
    padding: .3rem;
  }

  .dorak-game-brand {
    padding-left: 1.8rem;
    font-size: .7rem;
  }

  .dorak-game-brand::before {
    width: 1.25rem;
  }
}

@media (max-width: 780px) and (max-height: 620px) and (orientation: portrait) {
  .dorak-game-overlay {
    padding: .4rem;
  }

  .dorak-overlay-card {
    padding: .65rem;
  }

  .dorak-overlay-card h1 {
    margin: .2rem 0 .35rem;
    font-size: 1.45rem;
  }

  .dorak-overlay-card p {
    margin-bottom: .45rem;
    font-size: .72rem;
    line-height: 1.25;
  }

  .dorak-control-hints {
    display: none;
  }

  .glow-overlay-actions {
    flex-wrap: nowrap;
    gap: .4rem;
  }

  .glow-overlay-actions button {
    padding-inline: .55rem;
    font-size: .67rem;
  }

  .glow-overlay-actions [data-dorak-overlay-action="secondary"] {
    margin-top: 0;
  }

  .pause-setting {
    min-height: 3.2rem;
    margin-top: .5rem;
    padding: .4rem .55rem;
  }

  .pause-setting small {
    font-size: .58rem;
    line-height: 1.2;
  }
}

@media (max-width: 350px) {
  .dorak-game-header {
    gap: .35rem;
  }

  .dorak-game-brand {
    width: 1.45rem;
    padding-left: 1.45rem;
    overflow: hidden;
    color: transparent;
  }

  .dorak-game-brand::before {
    left: 0;
  }

  .dorak-status-chip {
    padding-inline: .45rem;
    font-size: .5rem;
  }
}
