﻿@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;600;700&family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --bg-deep: #050607;
  --bg-mid: #0d0f12;
  --panel: rgba(15, 18, 22, 0.82);
  --panel-border: rgba(174, 182, 194, 0.2);
  --text: #f0f3f7;
  --muted: #a8b0bf;
  --accent: #ff8a4f;
  --good: #49ca8b;
  --bad: #f06767;
  --button: rgba(31, 36, 44, 0.44);
  --button-hover: rgba(54, 60, 72, 0.62);
  --game-ratio: 1.7777778;
  --game-aspect: 1920 / 1080;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(130% 85% at 20% 15%, #16191f 0%, rgba(22, 25, 31, 0.12) 60%, transparent 100%),
    radial-gradient(120% 75% at 80% 10%, #11141a 0%, rgba(17, 20, 26, 0.1) 55%, transparent 100%),
    linear-gradient(160deg, var(--bg-deep), var(--bg-mid));
  overflow: hidden;
}

#bokeh-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

#bokeh-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 60% at 20% 30%, rgba(255, 180, 70, 0.08), transparent 70%),
    radial-gradient(75% 60% at 75% 65%, rgba(255, 75, 50, 0.06), transparent 74%);
  filter: blur(16px);
}

.bokeh {
  position: absolute;
  width: var(--size);
  height: var(--size);
  left: var(--x);
  top: var(--y);
  border-radius: 50%;
  opacity: 0;
  filter: blur(var(--blur));
  mix-blend-mode: screen;
  background: radial-gradient(circle, var(--core) 0%, var(--fade) 42%, rgba(0, 0, 0, 0) 72%);
  animation:
    bokehPulse var(--pulse) ease-in-out infinite,
    bokehDrift var(--drift) ease-in-out infinite;
  animation-delay: var(--delay), var(--delay);
}

@keyframes bokehPulse {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  22% {
    opacity: 0.42;
  }
  48% {
    opacity: 0.18;
    transform: scale(1.08);
  }
  80% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
    transform: scale(0.82);
  }
}

@keyframes bokehDrift {
  0% {
    translate: 0 0;
  }
  35% {
    translate: var(--dx1) var(--dy1);
  }
  70% {
    translate: var(--dx2) var(--dy2);
  }
  100% {
    translate: 0 0;
  }
}

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

.app-exit-btn {
  position: fixed;
  top: clamp(10px, 1.2vw, 18px);
  right: clamp(10px, 1.2vw, 18px);
  z-index: 20;
}

.app-fullscreen-btn {
  position: fixed;
  top: clamp(10px, 1.2vw, 18px);
  right: clamp(132px, 13.5vw, 188px);
  z-index: 20;
}

.panel,
.stage-wrap {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-radius: 18px;
  box-shadow:
    0 24px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.panel {
  padding: clamp(10px, 1.3vw, 14px);
}

#menuPanel {
  grid-row: 1 / -1;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

#menuPanel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("assets/bread slicer title.png");
  background-repeat: no-repeat;
  background-position: center 52%;
  background-size: min(74%, 980px) auto;
  opacity: 0.12;
  filter: saturate(0.78) brightness(1.05);
  pointer-events: none;
  z-index: 0;
}

#menuPanel > .menu-side-logo {
  position: absolute;
  top: 50%;
  width: clamp(230px, 22vw, 390px);
  height: clamp(420px, 78%, 920px);
  object-fit: fill;
  transform: translateY(-50%);
  opacity: 0.34;
  filter: saturate(0.95) brightness(1.05);
  pointer-events: none;
  z-index: 0;
  user-select: none;
}

#menuPanel > .menu-side-logo-left {
  left: clamp(-10px, 0.2vw, 8px);
}

#menuPanel > .menu-side-logo-right {
  right: clamp(-10px, 0.2vw, 8px);
}

#menuPanel > * {
  position: relative;
  z-index: 1;
}

.menu-screensaver {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#menuPanel.screensaver-active > .panel-header,
#menuPanel.screensaver-active > .menu-levels {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.panel-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.menu-toolbar {
  display: flex;
  gap: 10px;
  margin-top: 0;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.menu-levels {
  margin-top: 6px;
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(520px, 760px) minmax(170px, 220px);
  justify-content: center;
  gap: 10px;
  align-items: stretch;
}

.boss-lane {
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 100%;
  align-content: stretch;
}

.boss-lane .boss-level-card {
  min-height: 0;
  height: 100%;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.boss-lane .boss-level-card .level-title {
  font-size: 0.98rem;
}

.boss-lane .boss-level-card .level-meta {
  font-size: 0.82rem;
  margin-top: 5px;
}

.boss-lane .boss-level-card .level-controls {
  margin-top: 8px;
}

.boss-lane .boss-level-card .btn {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.boss-lane .boss-slot-placeholder {
  min-height: 0;
  height: 100%;
  padding: 10px;
  display: grid;
  place-items: center;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.08) 60%),
    rgba(22, 25, 31, 0.66);
}

.boss-placeholder-content {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.boss-placeholder-trophy {
  width: min(72px, 62%);
  height: auto;
  display: block;
  opacity: 0.26;
  filter: grayscale(0.2) saturate(0.7) brightness(0.95);
}

.boss-placeholder-label {
  font-size: 0.82rem;
  color: rgba(232, 236, 244, 0.58);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.level-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 280px));
  justify-content: center;
  gap: 10px;
}

.level-card {
  background: rgba(27, 31, 38, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px;
  transition: border-color 140ms ease, transform 140ms ease;
}

.level-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-thumb-inline {
  width: 30px;
  height: 22px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.28));
}

.level-card.focused {
  border-color: rgba(255, 197, 114, 0.72);
  transform: translateY(-2px);
}

.level-card.locked {
  opacity: 0.58;
}

.level-card.boss-level-card {
  border-color: rgba(229, 171, 89, 0.52);
  background:
    linear-gradient(130deg, rgba(74, 52, 30, 0.34), rgba(29, 22, 14, 0.22)),
    rgba(27, 31, 38, 0.86);
}

.level-title {
  margin: 0;
  font-weight: 700;
}

.level-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}
.trophy-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.trophy-meta-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trophy-badge-wrap {
  min-width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.trophy-badge {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.level-controls {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--button);
  color: var(--text);
  backdrop-filter: blur(6px);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  transition: background 120ms ease, border-color 120ms ease, translate 120ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--button-hover);
  border-color: rgba(255, 255, 255, 0.35);
  translate: 0 -1px;
}

.btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.btn.ghost {
  background: rgba(36, 41, 50, 0.34);
}

.btn.subtle {
  background: rgba(24, 27, 33, 0.38);
}

.btn.danger {
  background: rgba(121, 33, 33, 0.6);
  border-color: rgba(232, 119, 119, 0.55);
}

.btn.on {
  background: rgba(52, 123, 75, 0.62);
  border-color: rgba(150, 224, 164, 0.55);
}

.stage-wrap {
  position: relative;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  justify-self: center;
  aspect-ratio: var(--game-aspect);
  overflow: hidden;
}

body.gameplay-view .app-shell {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  margin: 0;
  padding: 0;
  gap: 0;
}

body.gameplay-view .stage-wrap {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-width: 100vw;
  min-height: 100vh;
  display: block;
  max-width: none;
  max-height: none;
  justify-self: stretch;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  z-index: 2;
}

body.gameplay-view #gameCanvas {
  width: 100%;
  height: 100%;
}

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

#gameCanvas.boss-cursor {
  cursor: none;
}

#runExitBtn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
}

:fullscreen .app-shell {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
  gap: 0;
}

:fullscreen .panel {
  border-radius: 0;
}

:fullscreen .stage-wrap {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(1, 2, 4, 0.65);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 25;
}

.modal-card {
  width: min(720px, 95vw);
  max-height: min(90vh, 980px);
  overflow: auto;
  background: rgba(16, 20, 26, 0.96);
  border: 1px solid rgba(182, 191, 205, 0.28);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55);
  animation: panelIn 220ms ease;
}
#upgradesModal .modal-card {
  width: min(980px, 97vw);
}

#musicModal .modal-card {
  width: min(920px, 97vw);
}

#leaderboardModal .modal-card {
  width: min(1080px, 98vw);
}

#leaderboardSubmitModal .modal-card {
  width: min(560px, 94vw);
}

#leaderboardVideoModal .modal-card {
  width: min(980px, 98vw);
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  position: sticky;
  top: -18px;
  z-index: 3;
  margin: -18px -18px 12px;
  padding: 12px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(16, 20, 26, 0.98), rgba(16, 20, 26, 0.92));
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.modal-card h2 {
  margin: 0;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
}

.modal-close-btn {
  color: #ff6c6c;
  border-color: rgba(255, 108, 108, 0.65);
  background: rgba(70, 20, 20, 0.22);
  font-weight: 700;
}

.modal-close-btn:hover:not(:disabled) {
  color: #ff8a8a;
  border-color: rgba(255, 138, 138, 0.82);
  background: rgba(92, 24, 24, 0.35);
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
}

.settings-list {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-item {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(28, 33, 41, 0.9);
  padding: 10px 12px;
}

.settings-item .field-label {
  margin-top: 0;
}

.settings-item-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="range"] {
  width: 100%;
  accent-color: #ff9d61;
}

.row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row.end {
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
  margin: 8px 0 0;
}

.settings-save-status.is-success {
  color: #91e7b8;
}

.settings-save-status.is-error {
  color: #ff9c9c;
}

.music-mode-row {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.music-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.92rem;
}

.music-help {
  font-size: 0.88rem;
}

.music-track-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaderboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 2px;
}

.leaderboard-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.leaderboard-tab {
  min-width: 88px;
}

.leaderboard-status {
  margin-top: 12px;
}

.leaderboard-table-wrap {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(28, 33, 41, 0.9);
  overflow: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 660px;
}

.leaderboard-table th,
.leaderboard-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: middle;
  font-size: 0.92rem;
}

.leaderboard-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(18, 22, 28, 0.96);
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  letter-spacing: 0.03em;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

.leaderboard-rank {
  font-weight: 700;
  color: #f8d18f;
}

.leaderboard-time {
  font-variant-numeric: tabular-nums;
}

.leaderboard-tier-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.leaderboard-tier-cell img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.leaderboard-empty {
  margin: 0;
  padding: 14px 12px;
}

.leaderboard-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(22, 27, 34, 0.9);
}

.leaderboard-page-info {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.leaderboard-export-hint {
  margin-top: 10px;
  font-size: 0.86rem;
}

.leaderboard-export-hint a {
  color: #ffd48a;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 212, 138, 0.5);
}

.leaderboard-export-hint a:hover,
.leaderboard-export-hint a:focus-visible {
  color: #ffe0a7;
  border-bottom-color: rgba(255, 224, 167, 0.9);
}

.leaderboard-submit-summary {
  margin: 2px 0 10px;
  color: var(--text);
}

.leaderboard-video-meta {
  margin: 2px 0 10px;
  color: #d9dde6;
}

.leaderboard-video-player {
  width: 100%;
  max-height: min(66vh, 760px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #040507;
  display: block;
}

#leaderboardNameInput {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(18, 22, 28, 0.86);
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
}

#leaderboardNameInput:focus-visible {
  outline: 2px solid rgba(255, 177, 96, 0.7);
  outline-offset: 2px;
}

.music-track-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(28, 33, 41, 0.9);
  padding: 10px 12px;
}

.music-track-row.active {
  border-color: rgba(255, 194, 116, 0.45);
}

.music-track-row.locked {
  border-style: dashed;
  border-color: rgba(173, 181, 194, 0.35);
  background: rgba(20, 24, 31, 0.82);
}

.music-track-info {
  min-width: 0;
}

.music-track-name {
  margin: 0;
  font-weight: 600;
}

.music-track-state {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.music-track-lock-line {
  color: #d7dde8;
}

.music-track-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.music-skip-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
}

.music-skip-option.disabled {
  opacity: 0.5;
}

.music-track-locked-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 3px 9px;
  font-size: 0.78rem;
  color: #b8c2d3;
  background: rgba(255, 255, 255, 0.05);
}

.upgrade-grid {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upgrade-cell {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px;
  background: rgba(28, 33, 41, 0.92);
}

.upgrade-cell.locked {
  border-color: rgba(164, 171, 183, 0.28);
}

.upgrade-cell.unlocked {
  border-color: rgba(255, 194, 116, 0.35);
}

.upgrade-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upgrade-name {
  margin: 0;
  font-weight: 600;
}

.upgrade-track {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  line-height: 1.25;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.upgrade-track.normal {
  background: rgba(255, 178, 89, 0.16);
  border-color: rgba(255, 178, 89, 0.42);
}

.upgrade-track.hard {
  background: rgba(226, 112, 112, 0.16);
  border-color: rgba(226, 112, 112, 0.42);
}

.upgrade-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.upgrade-requirement {
  margin: 9px 0 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
}

.upgrade-req-text {
  color: var(--muted);
}

.upgrade-req-tier {
  font-weight: 600;
}

.upgrade-req-trophy {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.upgrade-requirement.locked .upgrade-req-trophy {
  opacity: 0.3;
  filter: grayscale(1) saturate(0) brightness(0.9);
}

.upgrade-requirement.locked .upgrade-req-tier,
.upgrade-requirement.locked .upgrade-req-text {
  opacity: 0.72;
}

.upgrade-requirement.unlocked .upgrade-req-tier {
  color: #ffd48a;
}

.upgrade-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

body.high-contrast {
  --text: #ffffff;
  --muted: #f0f0f0;
  --panel-border: rgba(255, 255, 255, 0.5);
}

@media (max-width: 900px) {
  .app-exit-btn {
    top: 8px;
    right: 8px;
    padding: 8px 10px;
  }

  #menuPanel > .menu-side-logo {
    display: none;
  }

  .panel-header {
    gap: 8px;
    flex-wrap: wrap;
  }

  .menu-levels {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .boss-lane {
    grid-template-rows: none;
    min-height: 0;
  }

  .level-grid {
    grid-template-columns: 1fr;
  }

  .panel-header p {
    font-size: 0.88rem;
  }

  .leaderboard-toolbar {
    align-items: flex-start;
  }

  .leaderboard-tab {
    min-width: 74px;
    padding: 8px 10px;
  }

  .leaderboard-table {
    min-width: 560px;
  }
}
