:root {
  --bg: #0b1020;
  --panel: #171d2f;
  --panel2: #202840;
  --text: #f7f8fb;
  --muted: #a8b0c3;
  --accent: #67e8f9;
  --border: rgba(255,255,255,.12);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, #17203a 0%, var(--bg) 46%, #070a12 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
  display: flex;
  justify-content: center;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.app {
  width: min(100%, 780px);
  min-height: 100svh;
  padding: 12px 14px 20px;
}

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

h1 {
  font-size: clamp(26px, 6vw, 42px);
  line-height: 1;
  letter-spacing: .18em;
  margin: 0;
}

.sub {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.audio-notice {
  margin: -2px 0 10px;
  padding: 8px 10px;
  border: 1px solid rgba(250, 204, 21, .28);
  border-radius: 10px;
  background: rgba(113, 63, 18, .28);
  color: #fde68a;
  font-size: 11px;
  line-height: 1.45;
}

.audio-notice.hidden {
  display: none;
}

.small-btn,
.restart-btn {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 12px;
  align-items: start;
  justify-content: center;
}

.board-wrap {
  position: relative;
  width: min(100%, 420px);
  margin: 0 auto;
}

#game {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 2;
  background: #070b15;
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.34);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 16, .72);
  border-radius: 14px;
  backdrop-filter: blur(2px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  min-width: 160px;
  text-align: center;
  background: rgba(23,29,47,.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  font-size: 24px;
  font-weight: 900;
}

.overlay-card button {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent);
  color: #06131a;
  font-weight: 900;
}

.side-panel {
  display: grid;
  gap: 8px;
}

.panel-box {
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel-box span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
}

.panel-box strong {
  margin-top: 3px;
  font-size: 22px;
}

.next-box {
  align-items: center;
}

#next {
  width: 96px;
  height: 96px;
  margin-top: 4px;
  background: #0b1020;
  border-radius: 9px;
}

.setting-box {
  display: grid;
  gap: 6px;
}

.setting-btn {
  width: 100%;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #252c3d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
}

.setting-btn span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.setting-btn strong {
  min-width: 29px;
  font-size: 12px;
  text-align: right;
}

.setting-btn.is-on {
  background: linear-gradient(180deg, #164e63, #123847);
  border-color: rgba(103,232,249,.32);
}

.setting-btn.is-on strong {
  color: var(--accent);
}

.restart-btn {
  width: 100%;
  background: #7f1d1d;
}

.mobile-controls {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.control-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

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

.control-btn {
  flex: 1;
  min-height: 54px;
  max-width: 160px;
  border-radius: 14px;
  background: linear-gradient(180deg, #26314e, #172038);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 4px 0 #0a0f1c;
  font-size: 23px;
  font-weight: 900;
}

.control-btn span {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: #c4c9d5;
  font-weight: 700;
}

.control-btn:active,
.control-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0a0f1c;
}

.rotate {
  max-width: 210px;
}

.drop {
  max-width: 300px;
  background: linear-gradient(180deg, #155e75, #164e63);
}

.hint {
  text-align: center;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

@media (min-width: 760px) {
  .app {
    padding-top: 18px;
  }

  .mobile-controls {
    max-width: 520px;
    margin-inline: auto;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 8px 10px 12px;
  }

  .topbar {
    margin-bottom: 7px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) 94px;
    gap: 7px;
  }

  .panel-box {
    min-height: 50px;
    padding: 7px;
    border-radius: 10px;
  }

  .panel-box strong {
    font-size: 17px;
  }

  #next {
    width: 72px;
    height: 72px;
  }

  .restart-btn,
  .small-btn {
    padding: 8px 9px;
    font-size: 12px;
  }

  .setting-btn {
    min-height: 42px;
    padding: 5px 7px;
  }

  .setting-btn span {
    font-size: 9px;
  }

  .setting-btn strong {
    font-size: 11px;
  }

  .mobile-controls {
    margin-top: 8px;
    gap: 6px;
  }

  .control-btn {
    min-height: 47px;
    font-size: 20px;
    border-radius: 11px;
  }

  .hint {
    font-size: 10px;
  }
}

@media (max-height: 720px) and (orientation: portrait) {
  .sub,
  .hint {
    display: none;
  }

  .panel-box {
    min-height: 45px;
  }

  .control-btn {
    min-height: 42px;
  }

  .mobile-controls {
    margin-top: 6px;
  }
}
