:root {
  color-scheme: dark;
  --ink: #f4efe6;
  --muted: #9ca8ae;
  --panel: rgba(18, 23, 27, 0.74);
  --panel-strong: rgba(24, 31, 35, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --gold: #d5a85b;
  --teal: #55d6cb;
  --ruby: #d66c7a;
  --charcoal: #0d1114;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(213, 168, 91, 0.18), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(85, 214, 203, 0.12), transparent 32%),
    linear-gradient(135deg, #0b0e12 0%, #151719 46%, #0e1415 100%);
  color: var(--ink);
  overflow: hidden;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1440px, 100vw);
  height: 100vh;
  margin: 0 auto;
  padding: 18px;
  gap: 14px;
}

.topbar,
.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.topbar {
  padding: 10px 14px;
}

.bottombar {
  padding: 10px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(213, 168, 91, 0.55);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 47%, rgba(213, 168, 91, 0.55) 48% 52%, transparent 53%),
    radial-gradient(circle, rgba(244, 239, 230, 0.95) 0 13%, rgba(213, 168, 91, 0.18) 14% 45%, transparent 46%);
  box-shadow: 0 0 26px rgba(213, 168, 91, 0.24);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  inset: 8px 5px;
  content: "";
  border-top: 1px solid rgba(85, 214, 203, 0.65);
  transform: rotate(24deg);
}

.brand-mark::after {
  transform: rotate(-24deg);
}

.brand h1 {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  letter-spacing: 0;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 180px;
  padding: 10px 14px;
  border: 1px solid rgba(213, 168, 91, 0.24);
  border-radius: 8px;
  background: rgba(213, 168, 91, 0.09);
  color: #fff7e8;
  font-size: 14px;
}

.status-strip span + span {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 160px;
}

.icon-button,
.finish-toast button,
.level-track button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 22px;
}

.icon-button:hover,
.finish-toast button:hover,
.level-track button:hover:not(:disabled) {
  border-color: rgba(213, 168, 91, 0.56);
  background: rgba(213, 168, 91, 0.12);
  transform: translateY(-1px);
}

.icon-button:active,
.finish-toast button:active,
.level-track button:active:not(:disabled) {
  transform: translateY(0);
}

.play-surface {
  position: relative;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03), transparent 22% 72%, rgba(255, 255, 255, 0.04)),
    rgba(6, 8, 10, 0.84);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.42), 0 26px 90px rgba(0, 0, 0, 0.34);
}

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

.finish-toast {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(85, 214, 203, 0.4);
  border-radius: 8px;
  background: rgba(8, 15, 17, 0.82);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(18px);
}

.finish-toast span {
  color: #e9fff9;
  font-weight: 700;
}

.finish-toast button {
  min-height: 38px;
  padding: 0 14px;
  background: rgba(85, 214, 203, 0.12);
}

.level-track {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.level-track button {
  width: 38px;
  height: 38px;
  color: var(--muted);
  font-size: 14px;
}

.level-track button.is-active {
  border-color: rgba(85, 214, 203, 0.62);
  background: rgba(85, 214, 203, 0.13);
  color: #e8fffb;
}

.level-track button.is-complete {
  color: var(--gold);
}

.level-track button:disabled {
  cursor: default;
  opacity: 0.35;
}

.control-hints {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-width: 250px;
}

.control-hints span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    padding: 10px;
    gap: 10px;
  }

  .topbar,
  .bottombar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand,
  .tool-row,
  .status-strip,
  .control-hints {
    width: 100%;
    min-width: 0;
  }

  .tool-row,
  .control-hints,
  .level-track {
    justify-content: center;
  }

  .play-surface {
    height: min(68vh, 720px);
    min-height: 520px;
  }
}
