:root {
  --header-height: 64px;
  --bg-header: #000000;
  --bg-canvas: #0a1630;
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --panel-border: rgba(255, 255, 255, 0.14);
  --button-bg: #111111;
  --button-bg-hover: #1a1a1a;
  --button-border: rgba(255, 255, 255, 0.18);
  --accent-red: #d90429;
  --panel-bg: rgba(10, 18, 26, 0.96);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg-header);
  color: var(--text-main);
}

body {
  display: flex;
  flex-direction: column;
}

body.completion-mode .site-header {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.site-header {
  flex: 0 0 var(--header-height);
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--panel-border);
  position: relative;
  transition: opacity 180ms ease;
  min-width: 0;
  overflow: visible;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-left {
  flex: 1 1 auto;
  overflow: hidden;
}

.header-right {
  flex: 0 0 auto;
  justify-content: flex-end;
  overflow: visible;
}

.site-title {
  margin: 0;
  font-size: 24px;
  line-height: 1;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

.btn {
  appearance: none;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: #ffffff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.btn:hover {
  background: var(--button-bg-hover);
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: #ffffff;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
  flex: 0 0 auto;
}

.icon-btn:hover {
  background: var(--button-bg-hover);
  border-color: rgba(255, 255, 255, 0.26);
}

.icon-btn:active {
  transform: translateY(1px);
}

.icon-svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hud-board {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
}

.hud-board strong {
  color: #ffffff;
}

.sound-toggle {
  position: relative;
  overflow: hidden;
}

.sound-icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.sound-icon-off {
  opacity: 0;
  transform: scale(0.92);
}

.sound-toggle[data-muted="true"] .sound-icon-on {
  opacity: 0;
  transform: scale(0.92);
}

.sound-toggle[data-muted="true"] .sound-icon-off {
  opacity: 1;
  transform: scale(1);
}

.sound-toggle[data-muted="true"] {
  background: rgba(120, 120, 120, 0.16);
  color: #d6d6d6;
}

.preview-toggle {
  position: relative;
  overflow: hidden;
}

.eye-icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.eye-icon-off {
  opacity: 0;
  transform: scale(0.92);
}

.preview-toggle[data-active="true"] .eye-icon-on {
  opacity: 0;
  transform: scale(0.92);
}

.preview-toggle[data-active="true"] .eye-icon-off {
  opacity: 1;
  transform: scale(1);
}

.preview-toggle[data-active="true"] {
  border-color: rgba(140, 190, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(110, 168, 255, 0.14);
}


.settings-btn[aria-expanded="true"] {
  border-color: rgba(140, 190, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(110, 168, 255, 0.14);
}

.donate-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  overflow: visible;
}

.donate-btn {
  appearance: none;
  border: 1px solid rgba(180, 255, 180, 0.45);
  background: #b9f6b0;
  color: #114411;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.donate-btn:hover {
  background: #c8f9c0;
}

.bank-info {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 320px;
  max-width: 380px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(10, 18, 26, 0.97);
  color: #e5eef8;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 9999;
}

.bank-info.hidden {
  display: none;
}

.bank-info-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #b9f6b0;
}

.bank-info-line {
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 4px;
}

.bank-info-line:last-child {
  margin-bottom: 0;
}

.app-shell {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg-canvas);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-canvas);
}

.preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.06);
  opacity: 0;
  pointer-events: none;
  transition: opacity 3000ms linear;
}

.preview-overlay.hidden {
  display: none !important;
}

.preview-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.28));
}


#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: var(--bg-canvas);
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  justify-content: flex-start;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 180ms ease;
}

.settings-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.settings-panel {
  width: min(380px, 92vw);
  height: 100%;
  background: var(--panel-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 16px 0 36px rgba(0, 0, 0, 0.35);
  padding: 18px 16px 22px;
  overflow-y: auto;
  transform: translateX(0);
  transition: transform 180ms ease;
}

.settings-overlay.hidden .settings-panel {
  transform: translateX(-100%);
}

.settings-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-panel-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

.settings-panel-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.settings-close-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
}

.settings-section {
  padding: 14px 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.settings-row:last-child {
  margin-bottom: 0;
}

.settings-row-stack {
  align-items: flex-start;
}

.settings-label {
  font-size: 13px;
  color: var(--text-muted);
}

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

.settings-inline-stretch {
  width: 100%;
}

.settings-select {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 10, 18, 0.92);
  color: #ffffff;
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 13px;
  min-width: 140px;
  cursor: pointer;
}

.settings-select:focus,
.color-input:focus {
  outline: none;
  border-color: rgba(140, 190, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(110, 168, 255, 0.18);
}

.settings-select:disabled {
  opacity: 0.55;
  cursor: default;
}

.settings-value {
  font-size: 12px;
  color: #ffffff;
  min-width: 64px;
  text-align: right;
}

.settings-mini-btn {
  padding: 8px 10px;
  font-size: 12px;
}

.settings-range {
  width: min(220px, 100%);
  accent-color: #6ea8ff;
  cursor: pointer;
}

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-input {
  appearance: none;
  width: 42px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

.completion-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at center, rgba(255, 214, 102, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(2, 8, 20, 0.28), rgba(2, 8, 20, 0.42));
  backdrop-filter: blur(2px);
}

.completion-overlay.hidden {
  display: none;
}

.fireworks-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.completion-glow {
  position: absolute;
  width: min(56vw, 620px);
  height: min(56vw, 620px);
  border-radius: 50%;
  background:
    radial-gradient(
      circle,
      rgba(255, 219, 120, 0.22) 0%,
      rgba(255, 200, 80, 0.09) 30%,
      rgba(255, 200, 80, 0.03) 52%,
      transparent 72%
    );
  filter: blur(8px);
  pointer-events: none;
}

.completion-card {
  position: relative;
  z-index: 2;
  min-width: min(88vw, 420px);
  padding: 26px 34px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(20, 29, 44, 0.96), rgba(9, 14, 24, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-align: center;
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.4),
    0 0 28px rgba(255, 218, 112, 0.12);
  animation: completion-pop-in 420ms ease-out forwards;
}

.completion-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-shadow:
    0 0 12px rgba(255, 214, 102, 0.22),
    0 2px 8px rgba(0, 0, 0, 0.35);
}

.completion-subtitle {
  margin-top: 10px;
  font-size: 15px;
  color: rgba(232, 239, 255, 0.82);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.completion-time {
  margin-top: 14px;
  font-size: 18px;
  font-weight: 700;
  color: #ffd76a;
  letter-spacing: 0.04em;
  text-shadow:
    0 0 12px rgba(255, 215, 106, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.32);
}

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 16px;
  opacity: 0.95;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.18);
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform:
      translate3d(var(--confetti-drift, 0px), 110vh, 0)
      rotate(var(--confetti-rotate, 540deg));
    opacity: 0.15;
  }
}

@keyframes completion-pop-in {
  0% {
    transform: translateY(10px) scale(0.94);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 1200px) {
  .hud-board {
    gap: 10px;
    padding: 8px 10px;
    font-size: 12px;
  }
}

@media (max-width: 980px) {
  .site-header {
    gap: 10px;
    padding: 8px 12px;
  }

  .header-left,
  .header-right {
    gap: 8px;
  }

  .site-title {
    font-size: 20px;
  }

  .hud-board {
    display: none;
  }
}

@media (max-width: 720px) {
  .site-header {
    padding: 8px 10px;
    gap: 8px;
  }

  .site-title {
    font-size: 18px;
  }

  .btn,
  .icon-btn {
    border-radius: 10px;
  }

  .completion-card {
    min-width: min(90vw, 380px);
    padding: 22px 24px;
  }

  .completion-title {
    font-size: 28px;
  }

  .completion-subtitle {
    font-size: 13px;
  }

  .completion-time {
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .site-title {
    display: none;
  }

  .header-left {
    flex: 0 0 auto;
  }
}