:root {
  --bg: #0f1116;
  --panel: #151a22;
  --accent: #42e2b8;
  --grid: #222836;
  --text: #e8edf5;
  --muted: #98a1b3;
  --board-width: 320px;
  --side-width: 220px;
  --layout-gap: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top left, #1b2230, #0c0f15 55%, #0b0e13 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 8px 8px 20px;
}

.app {
  display: inline-grid;
  grid-template-columns: var(--board-width) var(--side-width);
  gap: var(--layout-gap);
  align-items: start;
  padding: 12px;
  width: auto;
  max-width: calc(100vw - 16px);
  background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

#disqus_thread {
  width: min(100%, 980px);
}

.top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.back:hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
}

.title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.5px;
  flex: 1;
  text-align: center;
}

.score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}

.score strong {
  font-size: 22px;
  color: var(--accent);
}

.stage {
  position: relative;
  width: var(--board-width);
  justify-self: start;
  background: var(--panel);
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
}

#board {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0d12;
  border: 1px solid rgba(255,255,255,0.08);
}

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

.overlay[hidden] {
  display: none;
}

.overlay-card {
  background: rgba(20, 26, 36, 0.9);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 20px 28px;
  border-radius: 12px;
  text-align: center;
  display: grid;
  gap: 10px;
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.start-btn {
  border: none;
  background: var(--accent);
  color: #0b0e13;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}

.start-btn:hover {
  filter: brightness(1.05);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: var(--side-width);
  justify-self: start;
}

.mobile-controls {
  display: none;
  grid-template-columns: 1fr;
  gap: 12px;
  background: var(--panel);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}

.dpad {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.dpad-mid {
  display: grid;
  gap: 10px;
}

.actions-pad {
  display: grid;
  grid-template-columns: 1fr 60px 60px;
  gap: 10px;
}

.ctrl-btn {
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 12px 10px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: transform 0.1s ease, background 0.2s ease;
}

.ctrl-btn:active {
  transform: scale(0.97);
  background: rgba(255,255,255,0.16);
}

.ctrl-btn.wide {
  font-size: 14px;
}

.label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

.next, .controls {
  background: var(--panel);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}

#next {
  display: block;
  background: #0a0d12;
  border: 1px solid rgba(255,255,255,0.08);
}

.controls ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.app > section[aria-label="테트리스 안내"] {
  grid-column: 1 / -1;
  width: 100%;
  background: var(--panel) !important;
  border-color: rgba(255,255,255,0.05) !important;
  color: var(--text);
}

.app > section[aria-label="테트리스 안내"] h2,
.app > section[aria-label="테트리스 안내"] h3 {
  color: var(--text);
}

.app > section[aria-label="테트리스 안내"] p,
.app > section[aria-label="테트리스 안내"] li {
  color: var(--text);
}

@media (max-width: 860px) {
  body {
    align-items: stretch;
    padding: 8px 8px 20px;
  }

  .app {
    grid-template-columns: 1fr;
    display: grid;
    width: 100%;
    max-width: none;
  }

  .panel {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .stage {
    width: 100%;
  }

  .next, .controls {
    flex: 1 1 180px;
  }

  .mobile-controls {
    display: grid;
  }
}
