:root {
  --bg-1: #ebf1f7;
  --bg-2: #cfdbe9;
  --text-main: #182330;
  --text-muted: #5d6f83;
  --accent: #167c6b;
  --accent-soft: rgba(22, 124, 107, 0.12);
  --viewer-bg-top: #fdfefe;
  --viewer-bg-bottom: #d7e2ee;
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(86, 145, 223, 0.24), transparent 26%),
    radial-gradient(circle at bottom right, rgba(35, 124, 110, 0.18), transparent 24%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--text-main);
}

button {
  font: inherit;
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #22a68d, #146f60);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    filter 140ms ease,
    opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

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

button:disabled {
  cursor: wait;
  opacity: 0.5;
  transform: none;
}

button.ghost {
  background: var(--accent-soft);
  color: var(--accent);
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 10px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100vh;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: min(70vh, 780px);
  align-items: center;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 15px;
  color: var(--text-muted);
}

.status-line {
  color: var(--text-muted);
}

.viewer {
  position: relative;
  flex: 1 1 auto;
  min-height: min(70vh, 780px);
  width: 100%;
  border-radius: 0;
  overflow: visible;
  touch-action: none;
  background: transparent;
}

.viewer::after {
  content: none;
}

.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.disk-control-strip {
  width: min(560px, calc(100% - 80px));
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-items: center;
  margin-top: -22px;
  margin-bottom: 4px;
}

.disk-control-group {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.disk-control-button {
  min-width: 42px;
  padding: 6px 10px;
  border-radius: 11px;
}

.panel {
  background: transparent;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.controls {
  padding: 12px;
  border-radius: 0;
  background: transparent;
}

.stage-tools {
  width: min(860px, 100%);
  padding: 8px 12px;
}

.stage-tools-row,
.controls-header,
.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stage-tools-row {
  justify-content: center;
  flex-wrap: wrap;
  column-gap: 12px;
  row-gap: 8px;
}

.stage-tools-actions,
.stage-tools-palette {
  width: 100%;
}

.stage-tools-palette {
  margin-bottom: 8px;
}

.sound-test-row {
  margin-bottom: 6px;
}

.sound-test-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.sound-test-button {
  min-width: 38px;
  padding: 6px 10px;
  border-radius: 10px;
}

.controls-header {
  justify-content: space-between;
}

.status-header {
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.stage-tools-label {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  min-width: fit-content;
}

.view-toggle-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

button.is-active {
  background: linear-gradient(180deg, #167c6b, #0f5f52);
  color: #fff;
}

.view-toggle-row button,
.tool-actions button {
  min-width: 0;
  padding: 8px 12px;
  border-radius: 12px;
}

.hidden {
  display: none !important;
}

.session-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.stat-card {
  padding: 10px;
  border-radius: 12px;
  background: transparent;
  text-align: center;
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
}

.leaderboard-empty {
  margin-top: 10px;
  color: var(--text-muted);
  text-align: center;
}

.leaderboard-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.move-log {
  margin-top: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.7;
  word-break: break-word;
}

.paint-palette {
  display: grid;
  grid-template-columns: repeat(8, 28px);
  gap: 8px;
}

.paint-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease;
}

.paint-swatch:hover {
  transform: translateY(-1px);
}

.paint-swatch.is-active {
  outline: 2px solid rgba(24, 35, 48, 0.16);
}

.paint-swatch.is-clear {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0 46%, rgba(24, 35, 48, 0.14) 46% 54%, rgba(255, 255, 255, 0.9) 54% 100%);
  color: var(--text-main);
  font-size: 10px;
  font-weight: 700;
}

.paint-palette-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.paint-palette,
.paint-palette-wrap,
.action-row {
  align-items: center;
}

.tool-actions {
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tool-actions button {
  padding: 8px 12px;
}

.custom-color-input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  vertical-align: middle;
  align-self: center;
  appearance: none;
  -webkit-appearance: none;
}

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

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

.paint-swatch:disabled,
.custom-color-input:disabled,
#paint-toggle-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: transparent;
  font-size: 13px;
}

.leaderboard-rank,
.leaderboard-name {
  font-weight: 700;
}

.leaderboard-meta,
.leaderboard-date {
  color: var(--text-muted);
}

.leaderboard-date {
  grid-column: 1 / -1;
}

.counter-card {
  text-align: center;
}

.counter-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.counter-label {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-shell {
    width: calc(100vw - 20px);
    padding: 10px 0;
  }

  .viewer {
    min-height: 400px;
  }

  .stage-tools-row {
    justify-content: center;
  }

  .panel .action-row {
    flex-direction: column;
  }

  .panel button {
    width: 100%;
  }

  .paint-palette-wrap {
    justify-content: center;
  }
}
