:root {
  color-scheme: light;
  --ink: #2c2230;
  --muted: #6e5b68;
  --paper: #fff8df;
  --panel: #fffdf1;
  --red: #f0544f;
  --blue: #2f8fd8;
  --yellow: #ffd166;
  --green: #34a853;
  --line: rgba(44, 34, 48, 0.16);
  --shadow: 0 16px 38px rgba(78, 46, 30, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family:
    ui-rounded, "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 209, 102, 0.5), transparent 18rem),
    linear-gradient(135deg, #8be0ff 0%, #ffe773 46%, #ff9f7a 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 2px solid rgba(44, 34, 48, 0.18);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(44, 34, 48, 0.18);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(44, 34, 48, 0.18);
}

button.primary {
  color: #fff;
  background: var(--green);
  border-color: rgba(0, 0, 0, 0.08);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  padding: 18px;
}

.game-panel,
.control-panel {
  background: rgba(255, 253, 241, 0.92);
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-panel {
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 10px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 3rem);
}

h2 {
  font-size: 1.02rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  gap: 8px;
  min-width: min(100%, 230px);
}

.stats div {
  padding: 7px 8px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid var(--line);
  text-align: center;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.stats strong {
  display: block;
  font-size: 1.25rem;
}

.stage-wrap {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(260px, 1fr) auto;
  gap: 10px;
  padding: 0 18px 12px;
}

.stage {
  position: relative;
  min-height: 260px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  border-radius: 8px;
  border: 3px solid #352739;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 18px, transparent 18px 36px),
    linear-gradient(180deg, #fff7bd, #f8d9a4);
}

.stage::before {
  content: "";
  position: absolute;
  inset: 48px 0 auto;
  height: 4px;
  background: rgba(255, 255, 255, 0.7);
}

.lane {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 3px solid rgba(44, 34, 48, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12)),
    rgba(255, 255, 255, 0.25);
}

.lane-left {
  --lane-color: var(--blue);
}

.lane-right {
  --lane-color: var(--red);
}

.lane-label {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--lane-color);
  border: 3px solid #fff;
  font-weight: 800;
}

.note-track {
  position: absolute;
  inset: 0;
}

.note {
  position: absolute;
  left: 50%;
  width: clamp(48px, 14vmin, 92px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9) 0 8%, transparent 9%),
    var(--lane-color);
  border: 5px solid #fff;
  box-shadow: 0 8px 0 rgba(44, 34, 48, 0.2);
  font-weight: 900;
}

.hit-ring {
  position: absolute;
  left: 50%;
  bottom: 26px;
  width: clamp(68px, 18vmin, 120px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 6px solid #fff;
  transform: translateX(-50%);
  box-shadow:
    0 0 0 5px var(--lane-color),
    inset 0 0 0 5px rgba(44, 34, 48, 0.12);
  background: rgba(255, 255, 255, 0.45);
}

.hit-ring.flash {
  animation: pop 160ms ease-out;
}

.judge {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 5;
  min-width: 9ch;
  padding: 9px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(44, 34, 48, 0.82);
  font-size: clamp(1.2rem, 4vmin, 2.2rem);
  font-weight: 900;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.drum-zone {
  display: grid;
  grid-template-columns: 1fr minmax(110px, 170px) 1fr;
  align-items: center;
  gap: 10px;
}

.drum-pad,
.drum-center {
  border-radius: 8px;
  min-height: 74px;
  font-weight: 900;
  font-size: 1.35rem;
}

.left-pad {
  color: #fff;
  background: var(--blue);
}

.right-pad {
  color: #fff;
  background: var(--red);
}

.drum-center {
  min-height: 104px;
  border-radius: 50%;
  color: #7c241f;
  background:
    radial-gradient(circle at center, #ffe4b8 0 46%, #b64d35 47% 53%, #f3c07d 54% 100%);
}

.play-controls,
.button-row {
  display: flex;
  gap: 8px;
}

.play-controls {
  padding: 0 18px 16px;
}

.play-controls button,
.button-row button {
  flex: 1;
}

.sound-status {
  margin: 0;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.85rem;
}

.control-panel {
  min-height: calc(100vh - 36px);
  padding: 14px;
  overflow: auto;
}

.readonly-mode .admin-only {
  display: none;
}

.panel-section {
  padding: 12px 0 16px;
  border-bottom: 2px dashed rgba(44, 34, 48, 0.16);
}

.panel-section:first-child {
  padding-top: 0;
}

.panel-section:last-child {
  border-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title button {
  min-height: 36px;
  padding: 0 12px;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.check-field {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-field span {
  grid-column: 1 / -1;
}

.check-field input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--green);
}

.check-field strong {
  font-size: 0.95rem;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 2px solid rgba(44, 34, 48, 0.16);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

input[type="file"] {
  padding: 8px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}

textarea {
  height: 128px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.grid-2,
.note-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.note-list {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.note-row {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(78px, 1fr) 42px;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid var(--line);
}

.note-row input,
.note-row select {
  min-height: 34px;
  padding: 5px 8px;
}

.hand-select {
  color: #fff;
  font-weight: 900;
}

.hand-select.left {
  background: var(--blue);
}

.hand-select.right {
  background: var(--red);
}

.note-row button {
  min-height: 32px;
  border-radius: 8px;
}

@keyframes pop {
  0% {
    transform: translateX(-50%) scale(1);
  }
  55% {
    transform: translateX(-50%) scale(1.14);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

@media (orientation: portrait), (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .game-panel,
  .control-panel {
    min-height: auto;
  }

  .game-panel {
    min-height: calc(100svh - 20px);
  }

  .game-header {
    display: grid;
  }

  .stage-wrap {
    padding-inline: 10px;
  }

  .stats {
    min-width: 0;
    width: 100%;
  }

  .drum-zone {
    grid-template-columns: 1fr 96px 1fr;
  }

  .drum-pad {
    min-height: 68px;
  }

  .drum-center {
    min-height: 92px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
    padding: 8px;
    gap: 8px;
  }

  .game-panel,
  .control-panel {
    height: calc(100svh - 16px);
    min-height: 0;
  }

  .game-header {
    padding: 8px 12px 6px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .stage-wrap {
    grid-template-columns: minmax(0, 1fr) 118px;
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    padding: 0 10px 8px;
  }

  .stage {
    min-height: 0;
  }

  .drum-zone {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
  }

  .drum-pad,
  .drum-center {
    min-height: 0;
    width: 100%;
    font-size: 1.1rem;
  }

  .drum-pad {
    flex: 1 1 0;
  }

  .drum-center {
    flex: 0 0 76px;
    border-radius: 50%;
  }

  .play-controls {
    padding: 0 10px 8px;
  }

  .play-controls button {
    min-height: 34px;
    font-size: 0.9rem;
  }
}
