:root {
  color-scheme: dark;
  --ink: #fff7e8;
  --muted: #d8cbb4;
  --paper: #070b10;
  --panel: rgba(12, 18, 24, 0.86);
  --line: rgba(255, 247, 232, 0.16);
  --danger: #ff6f4f;
  --gold: #f5c45b;
  --mint: #6de1a6;
  --blue: #68b7ff;
  --pink: #ff7ac3;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

body,
button {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(104, 183, 255, 0.72);
  outline-offset: 3px;
}

.breaker-app {
  position: relative;
  display: grid;
  width: 100vw;
  min-height: 100svh;
  align-content: start;
  grid-template-rows: auto;
  overflow: visible;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 12%, rgba(104, 183, 255, 0.18), transparent 28rem),
    radial-gradient(circle at 84% 14%, rgba(255, 122, 195, 0.14), transparent 29rem),
    radial-gradient(circle at 50% 90%, rgba(245, 196, 91, 0.1), transparent 24rem),
    linear-gradient(145deg, #07101a, #0c1017 52%, #151019);
}

.ambient-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 247, 232, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 247, 232, 0.035) 1px, transparent 1px);
  background-size: 50px 50px;
  mask-image: radial-gradient(circle at 50% 50%, black, transparent 74%);
  opacity: 0.34;
}

.titlebar,
.game-hud,
.game-stage-wrap {
  position: relative;
  z-index: 1;
}

.titlebar {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  padding: 10px clamp(14px, 4vw, 48px);
  background: linear-gradient(180deg, rgba(7, 11, 16, 0.9), rgba(7, 11, 16, 0.62));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand-link {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.brand,
.brand-title,
.game-nav,
.game-hud,
.hud-cluster,
.hud-status {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  color: #07100d;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.54), transparent 34%),
    linear-gradient(135deg, var(--blue), var(--gold));
  border: 1px solid rgba(255, 247, 232, 0.28);
  border-radius: 8px;
  box-shadow: 0 0 34px rgba(104, 183, 255, 0.24);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.8rem;
}

.brand-title {
  min-width: 0;
  align-items: flex-start;
  flex-direction: column;
  line-height: 1.05;
  white-space: nowrap;
}

.brand-title strong {
  font-size: 1.06rem;
}

.document-name {
  overflow: hidden;
  max-width: min(44vw, 430px);
  margin-top: 4px;
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  text-overflow: ellipsis;
}

.game-nav {
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.game-nav a,
.game-nav button {
  display: flex;
  min-height: 36px;
  align-items: center;
  padding: 8px 11px;
  color: inherit;
  background: rgba(255, 247, 232, 0.045);
  border: 1px solid rgba(255, 247, 232, 0.08);
  border-radius: 8px;
  font: inherit;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.game-nav a:hover,
.game-nav button:hover {
  color: var(--gold);
  background: rgba(255, 247, 232, 0.09);
  border-color: rgba(255, 247, 232, 0.18);
}

.game-nav a:active,
.game-nav button:active,
.menu-button:active,
.touch-bar button:active {
  transform: translateY(1px);
}

.game-nav button:disabled {
  color: var(--muted);
  background: rgba(255, 247, 232, 0.045);
  border-color: rgba(255, 247, 232, 0.12);
  cursor: not-allowed;
  opacity: 1;
}

.game-nav button:disabled:hover {
  color: var(--muted);
  background: rgba(255, 247, 232, 0.045);
  border-color: rgba(255, 247, 232, 0.12);
}

.game-nav .nav-cta {
  color: var(--ink);
  background: rgba(104, 183, 255, 0.1);
  border-color: rgba(104, 183, 255, 0.24);
}

.game-hud {
  width: 100vw;
  max-width: 100vw;
  min-width: 0;
  min-height: 78px;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  padding: 10px clamp(14px, 4vw, 48px);
  background: rgba(9, 14, 20, 0.58);
  border-bottom: 1px solid rgba(255, 247, 232, 0.1);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
}

.hud-cluster {
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.score-chip {
  position: relative;
  display: grid;
  min-width: 106px;
  gap: 2px;
  padding: 9px 13px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 40%),
    rgba(18, 24, 32, 0.82);
  border: 1px solid rgba(255, 247, 232, 0.13);
  border-radius: 8px;
  text-align: center;
}

.score-chip::before {
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  content: "";
  pointer-events: none;
}

.score-chip.current {
  background:
    linear-gradient(135deg, rgba(104, 183, 255, 0.15), transparent 42%),
    rgba(18, 24, 32, 0.86);
  border-color: rgba(104, 183, 255, 0.38);
}

.score-chip.level {
  border-color: rgba(255, 122, 195, 0.24);
}

.score-chip span {
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.64rem;
  font-weight: 850;
  text-transform: uppercase;
}

.score-chip strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 1.18rem;
}

.hud-status {
  display: grid;
  min-width: min(30vw, 240px);
  min-height: 72px;
  align-content: center;
  gap: 7px;
  padding: 9px 13px;
  background: rgba(18, 24, 32, 0.72);
  border: 1px solid rgba(255, 247, 232, 0.12);
  border-radius: 8px;
}

.status-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(245, 196, 91, 0.55);
}

body[data-game-state="playing"] .status-dot,
body[data-game-state="serve"] .status-dot {
  background: var(--blue);
  box-shadow: 0 0 18px rgba(104, 183, 255, 0.62);
}

body[data-game-state="paused"] .status-dot {
  background: var(--muted);
  box-shadow: 0 0 18px rgba(216, 203, 180, 0.42);
}

body[data-game-state="over"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(255, 111, 79, 0.62);
}

body[data-game-state="won"] .status-dot {
  background: var(--mint);
  box-shadow: 0 0 18px rgba(109, 225, 166, 0.7);
}

.round-status {
  min-width: 0;
  margin: 0;
  color: var(--gold);
  font-weight: 900;
  white-space: nowrap;
}

body[data-game-state="playing"] .round-status,
body[data-game-state="serve"] .round-status {
  color: var(--blue);
}

body[data-game-state="paused"] .round-status {
  color: var(--muted);
}

body[data-game-state="over"] .round-status {
  color: var(--danger);
}

body[data-game-state="won"] .round-status {
  color: var(--mint);
}

.break-progress {
  position: relative;
  width: min(190px, 100%);
  height: 5px;
  justify-self: center;
  overflow: hidden;
  background: rgba(255, 247, 232, 0.08);
  border: 1px solid rgba(255, 247, 232, 0.1);
  border-radius: 999px;
}

.break-progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--gold), var(--mint));
  border-radius: inherit;
  box-shadow: 0 0 18px rgba(104, 183, 255, 0.38);
  transition: width 180ms ease;
}

.power-readout {
  display: flex;
  min-width: 0;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.power-readout strong {
  overflow: hidden;
  max-width: min(220px, 58vw);
  color: var(--gold);
  text-overflow: ellipsis;
}

.game-stage-wrap {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2vw, 20px);
}

.game-stage {
  position: relative;
  width: min(100%, 1080px);
  max-width: 100%;
  min-width: 0;
  height: clamp(350px, 48vw, 620px);
  min-height: 350px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(104, 183, 255, 0.08), transparent 48%),
    #0b121a;
  border: 1px solid rgba(255, 247, 232, 0.18);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-stage::before {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(104, 183, 255, 0.08);
  border-radius: inherit;
  box-shadow: inset 0 0 88px rgba(104, 183, 255, 0.08);
  content: "";
  pointer-events: none;
}

.game-stage::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 9%, transparent 78%, rgba(7, 11, 16, 0.32)),
    repeating-linear-gradient(0deg, transparent 0 5px, rgba(255, 247, 232, 0.018) 5px 6px);
  content: "";
  pointer-events: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
}

.game-menu {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(7, 11, 16, 0.08), rgba(7, 11, 16, 0.44)),
    radial-gradient(circle at 50% 42%, rgba(104, 183, 255, 0.18), transparent 24rem);
  text-align: center;
  user-select: none;
}

.game-menu[hidden] {
  display: none;
}

.menu-card {
  position: relative;
  display: grid;
  min-width: min(430px, calc(100vw - 44px));
  justify-items: center;
  gap: 14px;
  padding: clamp(22px, 5vw, 34px);
  background: rgba(9, 15, 22, 0.76);
  border: 1px solid rgba(255, 247, 232, 0.16);
  border-radius: 8px;
  box-shadow: 0 22px 72px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
}

.menu-card::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(104, 183, 255, 0.08), transparent 58%);
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.menu-card > * {
  position: relative;
  z-index: 1;
}

.menu-kicker,
.menu-meta {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.menu-kicker {
  color: var(--blue);
}

.menu-brick-stack {
  display: grid;
  width: min(260px, 68vw);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 2px 0 0;
}

.menu-brick-stack span {
  height: 13px;
  background: linear-gradient(135deg, var(--blue), var(--gold));
  border: 1px solid rgba(255, 247, 232, 0.22);
  border-radius: 4px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

.menu-brick-stack span:nth-child(2),
.menu-brick-stack span:nth-child(5) {
  background: linear-gradient(135deg, var(--pink), var(--blue));
}

.menu-brick-stack span:nth-child(3),
.menu-brick-stack span:nth-child(4) {
  background: linear-gradient(135deg, var(--mint), var(--gold));
}

.game-menu strong {
  color: var(--ink);
  font-size: clamp(2.4rem, 6vw, 5.2rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.92;
}

.menu-meta {
  min-height: 30px;
  padding: 5px 12px;
  color: var(--gold);
  background: rgba(9, 15, 22, 0.58);
  border: 1px solid rgba(255, 247, 232, 0.16);
  border-radius: 999px;
}

.menu-button {
  min-height: 46px;
  padding: 10px 18px;
  color: #07100d;
  background: linear-gradient(135deg, var(--blue), var(--gold));
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
  font-size: 1rem;
  font-weight: 950;
  transition: transform 160ms ease, filter 160ms ease;
}

.menu-button:hover {
  filter: brightness(1.06);
}

.touch-bar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 3;
  display: none;
  width: min(354px, calc(100% - 24px));
  grid-template-columns: 1fr 1.35fr 1fr;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.touch-bar button {
  display: grid;
  min-height: 48px;
  place-items: center;
  color: var(--ink);
  background: rgba(9, 15, 22, 0.7);
  border: 1px solid rgba(255, 247, 232, 0.18);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 950;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  touch-action: none;
}

.touch-bar button[data-control="launch"] {
  color: #07100d;
  background: linear-gradient(135deg, var(--gold), var(--blue));
}

@media (pointer: coarse) {
  .touch-bar {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .game-nav a,
  .game-nav button,
  .menu-button {
    transition: none;
  }

  .game-nav a:hover,
  .game-nav button:hover,
  .menu-button:hover {
    transform: none;
    filter: none;
  }
}

@media (max-width: 860px) {
  .titlebar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .game-nav {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .game-nav::-webkit-scrollbar {
    display: none;
  }

  .game-hud {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .hud-status {
    width: min(100%, 470px);
    min-width: 0;
    align-self: center;
  }
}

@media (max-width: 560px) {
  .titlebar {
    width: calc(100vw - 2px);
    max-width: calc(100vw - 2px);
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-title strong {
    font-size: 0.94rem;
  }

  .document-name {
    max-width: 70vw;
  }

  .game-stage-wrap {
    align-items: flex-start;
    padding: 8px;
  }

  .game-stage {
    width: 100%;
    height: min(50svh, calc(100svh - 326px), 430px);
    min-height: 0;
  }

  .hud-cluster {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .score-chip {
    min-width: 0;
    padding: 8px 10px;
  }

  .score-chip strong {
    font-size: 1rem;
  }

  .hud-status {
    min-height: 66px;
  }

  .menu-card {
    min-width: min(340px, calc(100vw - 36px));
  }
}
