:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --board-bg: #1a4731;
  --board-line: #1e5c3a;
  --board-border: #2ea96b;
  --accent: #2ea96b;
  --accent2: #58d68d;
  --gold: #f0c040;
  --text: #e6edf3;
  --muted: #8b949e;
  --hint: rgba(88, 214, 141, 0.18);
  --hint-border: rgba(88, 214, 141, 0.5);
  --black-stone: radial-gradient(circle at 35% 30%, #555, #111 60%, #000);
  --white-stone: radial-gradient(circle at 35% 30%, #fff, #d0d0d0 60%, #aaa);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(46, 169, 107, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(46, 169, 107, 0.05) 0%, transparent 50%);
}

/* HEADER */
header {
  text-align: center;
  margin-bottom: 12px;
}

/* MODE TABS */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

/* MAIN CONTAINER */
.content-container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.mode-tab {
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.active {
  background: var(--accent);
  color: #0d1117;
}

header h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: 0.12em;
  color: var(--accent2);
  text-shadow: 0 0 30px rgba(88, 214, 141, 0.4);
  line-height: 1;
}

header p {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* LAYOUT */
.game-wrapper {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

/* SIDE PANEL */
.side-panel {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-card h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* SCORE */
.score-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.score-item {
  flex: 1;
  text-align: center;
  padding: 10px 6px;
  border-radius: 10px;
  background: var(--surface2);
  transition: transform 0.2s;
}

.score-item.active {
  outline: 2px solid var(--accent);
  transform: scale(1.04);
}

.score-stone {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin: 0 auto 6px;
}

.score-stone.black {
  background: var(--black-stone);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}

.score-stone.white {
  background: var(--white-stone);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.score-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  line-height: 1;
  color: var(--text);
}

.score-label {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
}

.score-vs {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  color: var(--muted);
}

/* STATUS */
#status-text {
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--accent2);
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

#status-text.cpu {
  color: var(--gold);
}

#status-text.gameover {
  color: #ff7b7b;
}

/* CPU LEVEL */
.level-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level-btn {
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.78rem;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.level-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(46, 169, 107, 0.1);
}

.level-btn.active {
  border-color: var(--accent);
  color: var(--accent2);
  background: rgba(46, 169, 107, 0.15);
}

.level-btn .dots {
  display: flex;
  gap: 3px;
}

.level-btn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--muted);
  transition: all 0.2s;
}

.level-btn.active .dot.filled,
.level-btn:hover .dot.filled {
  background: var(--accent2);
  border-color: var(--accent2);
}

/* RESET BUTTON */
.reset-btn {
  width: 100%;
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: 10px;
  color: var(--accent2);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 11px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.2s;
}

.reset-btn:hover {
  background: var(--accent);
  color: #0d1117;
}

/* BOARD */
.board-wrap {
  position: relative;
}

.board-container {
  background: var(--board-bg);
  border: 3px solid var(--board-border);
  border-radius: 4px;
  box-shadow:
    0 0 40px rgba(46, 169, 107, 0.25),
    0 16px 48px rgba(0, 0, 0, 0.6);
  padding: 4px;
  position: relative;
}

#board {
  display: grid;
  grid-template-columns: repeat(8, 56px);
  grid-template-rows: repeat(8, 56px);
}

.cell {
  width: 56px;
  height: 56px;
  border: 1px solid var(--board-line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.cell:hover {
  background: rgba(255, 255, 255, 0.04);
}

.cell.can-place {
  cursor: pointer;
}

.cell.can-place::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--hint);
  border: 1.5px solid var(--hint-border);
  pointer-events: none;
  animation: hintPulse 1.8s ease-in-out infinite;
}

@keyframes hintPulse {

  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.stone {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: none;
  position: relative;
  z-index: 1;
  transition: transform 0.15s;
}

.cell:hover .stone {
  transform: scale(1.04);
}

.stone.black {
  display: block;
  background: var(--black-stone);
  box-shadow: 3px 4px 8px rgba(0, 0, 0, 0.7), inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.stone.white {
  display: block;
  background: var(--white-stone);
  box-shadow: 3px 4px 8px rgba(0, 0, 0, 0.4), inset 0 1px 4px rgba(255, 255, 255, 0.8);
}

.stone.flipping {
  animation: flip 0.35s ease-in-out;
}

@keyframes flip {
  0% {
    transform: rotateY(0deg) scale(1);
  }

  50% {
    transform: rotateY(90deg) scale(0.85);
  }

  100% {
    transform: rotateY(0deg) scale(1);
  }
}

.stone.placing {
  animation: place 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes place {
  0% {
    transform: scale(0.3);
    opacity: 0.5;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* RESULT OVERLAY */
#result-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

#result-overlay.show {
  display: flex;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--board-border);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 0 60px rgba(46, 169, 107, 0.3), var(--shadow);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw;
  position: relative;
}

@keyframes popIn {
  from {
    transform: scale(0.5);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.result-emoji {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.result-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.6rem;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.result-score {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 28px;
}

.result-btn {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #0d1117;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 12px 32px;
  cursor: pointer;
  transition: all 0.2s;
}

.result-btn:hover {
  background: var(--accent2);
  transform: translateY(-2px);
}

/* THINKING INDICATOR */
.thinking-dots span {
  animation: blink 1.2s infinite;
  opacity: 0;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {

  0%,
  100% {
    opacity: 0;
  }

  50% {
    opacity: 1;
  }
}

/* RESET BUTTON (outside game-wrapper) */
.reset-btn {
  display: block;
  margin: 16px auto 0;
  max-width: 300px;
  width: 100%;
}

/* ONLINE LOBBY */
#online-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 150;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

#online-overlay.show {
  display: flex;
}

.online-lobby {
  max-width: 360px;
  position: relative;
}

.close-lobby-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s;
  z-index: 10;
}

.close-lobby-btn:hover {
  color: var(--text);
}

.lobby-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin: 12px 0 4px;
  letter-spacing: 0.2em;
}

.lobby-room-id {
  text-align: center;
  margin-top: 20px;
}

.lobby-room-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
}

.lobby-room-code {
  font-family: 'Bebas Neue', monospace;
  font-size: 2.8rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(46, 169, 107, 0.4);
  user-select: all;
}

.lobby-status {
  text-align: center;
  color: var(--text);
  font-size: 0.85rem;
  margin-top: 16px;
}

.online-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

/* CHEAT MODE TOGGLE */
.cheat-card {
  padding: 10px 16px;
}

.cheat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.cheat-icon {
  font-size: 1.1rem;
}

.cheat-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  flex: 1;
  transition: color 0.2s;
  white-space: nowrap;
}

.level-change-hint {
  font-size: 0.6rem;
  color: var(--muted);
  opacity: 0.5;
}

.cheat-toggle input {
  display: none;
}

.cheat-slider {
  width: 40px;
  height: 22px;
  background: var(--surface2);
  border-radius: 11px;
  position: relative;
  transition: background 0.3s;
  flex-shrink: 0;
}

.cheat-slider::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  top: 3px;
  left: 3px;
  transition: all 0.3s;
}

.cheat-toggle input:checked~.cheat-slider {
  background: rgba(168, 85, 247, 0.4);
}

.cheat-toggle input:checked~.cheat-slider::after {
  left: 21px;
  background: #a855f7;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

.cheat-toggle input:checked~.cheat-label {
  color: #a855f7;
}

/* WIN RATE BADGE */
.win-rate-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 900;
  font-family: 'Bebas Neue', sans-serif;
  border-radius: 2px;
  z-index: 10;
  pointer-events: none;
  line-height: 1;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  animation: fadeInBadge 0.3s ease;
}

@keyframes fadeInBadge {
  from {
    opacity: 0;
    transform: scale(0.7);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.win-rate-badge.rate-high {
  background: rgba(46, 169, 107, 0.45);
  color: #fff;
}

.win-rate-badge.rate-mid {
  background: rgba(240, 192, 64, 0.4);
  color: #fff;
}

.win-rate-badge.rate-low {
  background: rgba(255, 80, 80, 0.4);
  color: #fff;
}

/* BEST MOVE GLOW */
.cell.best-move {
  box-shadow: inset 0 0 16px rgba(46, 169, 107, 0.7);
}

/* WIN RATE GRAPH */
.graph-container {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 14px;
  padding: 14px 16px 10px;
  box-shadow: var(--shadow);
  max-width: 900px;
  width: 100%;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
}

.graph-container h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 8px;
}

#win-rate-graph {
  width: 100%;
  height: 140px;
  display: block;
  border-radius: 6px;
}

/* SOUND TOGGLE */
.cheat-toggle input:checked~.sound-slider {
  background: rgba(46, 169, 107, 0.4);
}

.cheat-toggle input:checked~.sound-slider::after {
  left: 21px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(46, 169, 107, 0.6);
}

/* RESULT BUTTONS */
.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.result-btn.secondary {
  background: var(--surface2);
  color: var(--text);
}

.result-btn.secondary:hover {
  background: var(--muted);
  color: #0d1117;

}

/* NAME INPUT DIALOG */
#name-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 150;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

#name-overlay.show {
  display: flex;
}

.name-card {
  max-width: 340px;
}

.name-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.name-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}

.name-dot.black {
  background: var(--black-stone);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.name-dot.white {
  background: var(--white-stone);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.name-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--muted);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}

.name-row input:focus {
  border-color: var(--accent);
}

/* REVIEW MOVE STONE INDICATOR */
.review-move-item .move-stone {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.review-move-item .move-stone.is-black {
  background: var(--black-stone);
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.review-move-item .move-stone.is-white {
  background: var(--white-stone);
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* REVIEW OVERLAY */
#review-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
}

#review-overlay.show {
  display: flex;
}

.review-panel {
  background: var(--surface);
  border: 1px solid var(--board-border);
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: popIn 0.3s ease;
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface2);
}

.review-header h2 {
  font-size: 1.1rem;
  color: var(--accent2);
}

.review-close {
  background: var(--surface2);
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.review-close:hover {
  background: var(--accent);
  color: #0d1117;
}

.review-body {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  flex-wrap: wrap;
}

.review-board-wrap {
  flex-shrink: 0;
}

.review-board-container {
  background: var(--board-bg);
  border: 2px solid var(--board-border);
  border-radius: 4px;
  padding: 2px;
}

#review-board {
  display: grid;
  grid-template-columns: repeat(8, 36px);
  grid-template-rows: repeat(8, 36px);
}

#review-board .cell {
  width: 36px;
  height: 36px;
  border: 1px solid var(--board-line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#review-board .stone {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: none;
}

#review-board .stone.black {
  display: block;
  background: var(--black-stone);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#review-board .stone.white {
  display: block;
  background: var(--white-stone);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

#review-board .cell.last-move {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

#review-board .cell.best-alt {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.review-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.review-nav-btn {
  background: var(--surface2);
  border: 1px solid var(--muted);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  width: 36px;
  height: 32px;
  cursor: pointer;
  transition: all 0.2s;
}

.review-nav-btn:hover {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
}

.review-nav-btn.active {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
  animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 0 rgba(46, 169, 107, 0.7);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(46, 169, 107, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(46, 169, 107, 0);
  }
}

#review-step-label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 60px;
  text-align: center;
}

.review-moves {
  flex: 1;
  min-width: 200px;
  max-height: 340px;
  overflow-y: auto;
}

.review-move-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.78rem;
}

.review-move-item:hover {
  background: var(--surface2);
}

.review-move-item.active {
  background: rgba(46, 169, 107, 0.15);
}

.review-move-item .move-num {
  color: var(--muted);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.9rem;
  min-width: 24px;
}

.review-move-item .move-icon {
  font-size: 1rem;
}

.review-move-item .move-detail {
  flex: 1;
  color: var(--text);
}

.review-move-item .move-score {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.85rem;
}

.move-score.good {
  color: var(--accent2);
}

.move-score.ok {
  color: var(--gold);
}

.move-score.bad {
  color: #ff7b7b;
}

/* LEVEL OVERLAY */
#level-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 150;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

#level-overlay.show {
  display: flex;
}

.level-card {
  max-width: 360px;
}

.level-card {
  max-width: 360px;
}

/* TITLE SCREEN */
#title-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(46, 169, 107, 0.15) 0%, transparent 60%);
}

.title-content {
  width: 100%;
  max-width: 600px;
  padding: 20px;
  animation: fadeIn 0.8s ease-out;
}

.title-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(4rem, 10vw, 6rem);
  letter-spacing: 0.15em;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(46, 169, 107, 0.6);
  margin-bottom: 8px;
  line-height: 1;
}

.title-sub {
  font-size: 1.1rem;
  color: var(--muted);
  letter-spacing: 0.3em;
  margin-bottom: 48px;
  text-transform: uppercase;
  font-weight: 700;
}

.mode-select-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
  margin: 0 auto;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.mode-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(46, 169, 107, 0.2);
  background: linear-gradient(90deg, var(--surface) 0%, rgba(46, 169, 107, 0.05) 100%);
}

.mode-icon {
  font-size: 2.2rem;
  background: var(--surface2);
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
}

.mode-card:hover .mode-icon {
  transform: rotate(10deg) scale(1.1);
  background: var(--accent);
  color: #0d1117;
}

.mode-info {
  flex: 1;
}

.mode-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.mode-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

/* CONFIRM RESET OVERLAY */
#confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 160;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

#confirm-overlay.show {
  display: flex;
}

.confirm-card {
  max-width: 340px;
}

/* TURN SELECT OVERLAY */
#turn-select-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 160;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

#turn-select-overlay.show {
  display: flex;
}

.level-card .level-grid {
  margin-top: 16px;
}

@media (max-width: 600px) {
  .game-wrapper {
    flex-direction: column;
    align-items: center;
  }

  .board-wrap {
    order: 0;
  }

  /* ボードが最上部 */
  .side-panel {
    width: 100%;
    max-width: 448px;
    flex-direction: row;
    flex-wrap: wrap;
    order: 1;
  }

  .panel-card {
    flex: 1;
    min-width: 140px;
  }

  .panel-card[style*="padding:12px 16px"] {
    flex: 0 0 100%;
  }

  /* ステータスは全幅 */
  #board {
    grid-template-columns: repeat(8, calc((100vw - 60px) / 8));
    grid-template-rows: repeat(8, calc((100vw - 60px) / 8));
  }

  .cell {
    width: calc((100vw - 60px) / 8);
    height: calc((100vw - 60px) / 8);
  }

  .stone {
    width: 85%;
    height: 85%;
  }

  .win-rate-badge {
    font-size: 0.85rem;
  }

  .review-body {
    flex-direction: column;
  }

  #review-board {
    grid-template-columns: repeat(8, calc((100vw - 100px) / 8));
    grid-template-rows: repeat(8, calc((100vw - 100px) / 8));
  }

  #review-board .cell {
    width: calc((100vw - 100px) / 8);
    height: calc((100vw - 100px) / 8);
  }

  #review-board .stone {
    width: 80%;
    height: 80%;
  }
}

/* Lobby UI Refinement */
.lobby-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  display: block;
  margin-bottom: 6px;
  text-align: left;
  font-weight: 600;
}

.lobby-input {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #161b22;
  color: #fff;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.lobby-input:focus {
  border-color: var(--accent);
  outline: none;
  background: #1c2128;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.lobby-input::placeholder {
  color: #444;
  font-size: 0.9rem;
  letter-spacing: normal;
}

.input-group {
  display: flex;
  gap: 8px;
}

/* Overwrite existing lobby-divider for better look */
.lobby-divider {
  margin: 24px 0;
  position: relative;
  text-align: center;
}

.lobby-divider span {
  background: #0d1117;
  padding: 0 12px;
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  font-weight: bold;
}

.lobby-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #30363d;
  z-index: 0;
}

/* Lobby Tabs */
.lobby-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}

.lobby-tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 600;
}

.lobby-tab.active {
  background: var(--accent);
  color: #0d1117;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.lobby-tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.lobby-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.lobby-content.active {
  display: block;
}

/* LEVEL SELECTION ADJUSTMENTS */
.level-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

#level-overlay .result-title {
  margin-bottom: 0;
}

/* SCORE CARD & RESULT BUTTONS */
.score-display {
  display: flex;
  justify-content: center;
  gap: 16px;
  align-items: center;
}

.score-card {
  flex: 1;
  background: var(--surface2);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  transition: all 0.3s;
  border: 2px solid transparent;
  min-width: 100px;
  position: relative;
}

.score-name {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.score-name span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
  display: inline-block;
  vertical-align: middle;
}

.edit-name-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.edit-name-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.score-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--text);
}

#show-result-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: slideUp 0.5s ease-out;
}

#show-result-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 8px 20px rgba(46, 169, 107, 0.4);
}

.review-close:hover {
  color: var(--text) !important;
  transform: scale(1.1);
}

/* =========================================================================
   Side Panel Layout & Reactions
   ========================================================================= */
.panel-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 0px;
  /* カード自体のマージンに依存 */
}

/* 名前変更などのクリックできるカード */
.panel-card.cheat-card[onclick] {
  cursor: pointer;
  transition: transform 0.1s;
}

.panel-card.cheat-card[onclick]:active {
  transform: scale(0.98);
}

.cheat-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  /* justify-content: space-between;  <- 既存スタイル */
}

/* オンライン・リアクションバー */
.reaction-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  padding: 10px;
  background: rgba(22, 27, 34, 0.8);
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

.reaction-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s;
  padding: 4px;
  border-radius: 50%;
}

.reaction-btn:hover {
  transform: scale(1.2);
  background: rgba(255, 255, 255, 0.1);
}

.reaction-btn:active {
  transform: scale(0.9);
}

.reaction-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  background: none !important;
}

/* リアクションポップアップ */
.reaction-popup {
  position: absolute;
  font-size: 4rem;
  pointer-events: none;
  animation: reactionPop 1.5s forwards;
  z-index: 9999;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  left: 50%;
  transform: translateX(-50%);
}

.reaction-popup.is-me {
  top: 70%;
}

.reaction-popup.is-opponent {
  top: 30%;
}

@keyframes reactionPop {
  0% {
    transform: translateX(-50%) scale(0);
    opacity: 0;
  }

  20% {
    transform: translateX(-50%) scale(1.2);
    opacity: 1;
  }

  30% {
    transform: translateX(-50%) scale(1.0);
    opacity: 1;
  }

  80% {
    transform: translateX(-50%) scale(1.0);
    opacity: 1;
  }

  100% {
    transform: translateX(-50%) scale(1.5);
    opacity: 0;
  }
}