:root {
  color-scheme: light dark;
  font-family: "Inter", system-ui, sans-serif;
  background: #0c0f14;
  color: #e6eef7;
}

body {
  margin: 0;
}

.site-header {
  background: #141b2a;
  border-bottom: 2px solid #27324a;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #e6eef7;
  text-decoration: none;
  transition: color 0.2s;
  letter-spacing: -0.02em;
}

.site-title:hover {
  color: #4d78ff;
}

.player-id-top {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 10px;
  background: #0f1422;
  border: 1px solid #27324a;
  font-size: 0.85rem;
  color: #8a9cb5;
}

.player-id-top-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.player-id-top-value {
  font-weight: 700;
  color: #e6eef7;
  font-variant-numeric: tabular-nums;
}

.menu-toggle {
  background: none;
  border: 2px solid #27324a;
  color: #e6eef7;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.menu-toggle:hover {
  border-color: #4d78ff;
  background: rgba(77, 120, 255, 0.1);
}

.menu-icon {
  font-size: 1.4rem;
  line-height: 1;
  display: block;
}

.game-menu {
  position: absolute;
  top: 100%;
  right: 32px;
  margin-top: 8px;
  background: #1a2332;
  border: 2px solid #27324a;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 200px;
  z-index: 1000;
}

.game-menu.hidden {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: #e6eef7;
  text-decoration: none;
  transition: background 0.2s;
  border-bottom: 1px solid #27324a;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: rgba(77, 120, 255, 0.15);
}

.menu-item-icon {
  font-size: 1.5rem;
  line-height: 1;
  width: 24px;
  text-align: center;
  display: inline-block;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px;
  background: radial-gradient(circle at top, #182336, #0c0f14 60%);
}

.card {
  width: min(880px, 96vw);
  background: #141b2a;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.card header h1,
.card header h2 {
  margin: 0 0 8px;
}

/* ─── Game Selection Grid ─── */

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.game-card {
  background: #1a2332;
  border: 2px solid #27324a;
  border-radius: 14px;
  padding: 32px 24px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #e6eef7;
  font-family: inherit;
}

.game-card:hover {
  border-color: #4d78ff;
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(77, 120, 255, 0.2);
}

.game-card-icon {
  font-size: 3rem;
  line-height: 1;
}

.game-card h2 {
  margin: 0;
  font-size: 1.4rem;
}

.game-card p {
  margin: 0;
  font-size: 0.9rem;
  color: #8a9cb5;
  line-height: 1.4;
}

/* ─── Back button ─── */

.back-btn {
  background: none;
  border: none;
  color: #8a9cb5;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
}

.back-btn:hover {
  color: #4d78ff;
}

/* ─── Shared panel / form ─── */

.panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #27324a;
  background: #0f1422;
  color: #e6eef7;
}

button {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: #4d78ff;
  color: #fefeff;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #2c354d;
}

.hidden {
  display: none !important;
  visibility: hidden !important;
}

/* ─── Go Board ─── */

.board {
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: 2px;
  background: #b28b55;
  padding: 12px;
  border-radius: 12px;
  margin-top: 16px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  max-width: 100%;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.game-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 16px;
  background: #1a2332;
  border-radius: 10px;
  border: 1px solid #27324a;
}

.status-left {
  flex: 1;
  min-width: 0;
}

.status-left p {
  margin: 0;
  font-weight: 600;
  color: #4d78ff;
}

.status-center {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 0 16px;
}

.score-display {
  display: flex;
  gap: 20px;
}

.score {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(77, 120, 255, 0.1);
}

.score.black {
  color: #f5f2ed;
  background: rgba(21, 21, 21, 0.3);
}

.score.white {
  color: #b28b55;
  background: rgba(179, 139, 85, 0.2);
}

.status-right {
  display: flex;
  gap: 8px;
}

.cell {
  background: #d9b47d;
  border: 1px solid rgba(0, 0, 0, 0.2);
  aspect-ratio: 1 / 1;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(77, 120, 255, 0.3);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  min-width: 30px;
  min-height: 30px;
}

.stone {
  position: absolute;
  top: 12%;
  left: 12%;
  width: 76%;
  height: 76%;
  border-radius: 50%;
}

.stone.black {
  background: #151515;
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.1);
}

.stone.white {
  background: #f5f2ed;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.2);
}

/* ─── Chess Board ─── */

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 16px;
  border: 3px solid #27324a;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.chess-cell {
  aspect-ratio: 1 / 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  font-size: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: rgba(77, 120, 255, 0.3);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  min-width: 35px;
  min-height: 35px;
}

.chess-cell.light {
  background: #ebd7b2;
}

.chess-cell.dark {
  background: #b48764;
}

.chess-cell.selected {
  background: #f6f682 !important;
}

.chess-cell:hover {
  filter: brightness(1.1);
}

.chess-piece {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
}

.chess-piece.white {
  color: #fff;
  text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

.chess-piece.black {
  color: #1a1a1a;
}

.move-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 1;
}

.capture-hint {
  position: absolute;
  top: 4%;
  left: 4%;
  width: 92%;
  height: 92%;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 1;
}

.chess-label {
  position: absolute;
  font-size: 0.6rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.6;
}

.chess-label.rank {
  top: 2px;
  left: 3px;
}

.chess-label.file {
  bottom: 2px;
  right: 3px;
}

.chess-cell.light .chess-label { color: #b48764; }
.chess-cell.dark .chess-label { color: #ebd7b2; }

/* ─── Tic Tac Toe Board ─── */

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(60px, 1fr));
  gap: 10px;
  margin-top: 16px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.ttt-cell {
  aspect-ratio: 1 / 1;
  background: #1a2332;
  border: 2px solid #27324a;
  border-radius: 12px;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  color: #e6eef7;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.ttt-cell:hover {
  border-color: #4d78ff;
  transform: translateY(-2px);
}

.ttt-cell:disabled {
  cursor: default;
  transform: none;
  opacity: 0.9;
}

.ttt-cell.x { color: #4d78ff; }
.ttt-cell.o { color: #f5b66f; }

/* ─── Game Over Banner ─── */

.game-over-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.game-over-content {
  background: #1a2332;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.game-over-content h2 {
  margin: 0 0 16px;
  font-size: 2rem;
  color: #4d78ff;
}

.game-over-content p {
  margin: 0 0 24px;
  font-size: 1.1rem;
}

#go-waiting-text,
#chess-waiting-text,
#ttt-waiting-text {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: #8a9cb5;
}

/* ─── Waiting Banner ─── */

.waiting-banner {
  background: rgba(77, 120, 255, 0.1);
  border: 2px solid #4d78ff;
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  text-align: center;
}

.waiting-banner-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.waiting-banner-content p {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #4d78ff;
}

.waiting-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(77, 120, 255, 0.2);
  border-top-color: #4d78ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Responsive adjustments for mobile ─── */

@media (min-width: 480px) {
  .cell {
    min-width: 40px;
    min-height: 40px;
  }
  
  .chess-cell {
    min-width: 50px;
    min-height: 50px;
  }
}

@media (min-width: 640px) {
  .cell {
    min-width: 44px;
    min-height: 44px;
  }
  
  .chess-cell {
    min-width: 60px;
    min-height: 60px;
  }
}

/* Player ID Display */
.player-id-display {
  margin-bottom: 16px;
}

.player-id-display label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #a8b8d8;
}

.id-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.player-id-input {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  background: #1a2332;
  border: 2px solid #4d78ff;
  color: #4d78ff;
  padding: 12px;
  border-radius: 8px;
  cursor: default;
}

.copy-btn {
  background: #27324a;
  border: 2px solid #27324a;
  color: #e6eef7;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.copy-btn:hover {
  background: #4d78ff;
  border-color: #4d78ff;
  transform: scale(1.05);
}

.copy-btn:active {
  transform: scale(0.95);
}

.player-id-display small {
  display: block;
  margin-top: 6px;
  color: #7a8ca8;
  font-size: 0.875rem;
}

.divider {
  text-align: center;
  color: #7a8ca8;
  margin: 20px 0;
  position: relative;
  font-size: 0.875rem;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #27324a;
}

.divider::before {
  left: 0;
}

.divider::after {
  right: 0;
}

/* JC Tracker styles */
.jc-tracker-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.jc-counter-section {
  text-align: center;
  padding: 2rem;
  background: rgba(39, 50, 74, 0.5);
  border-radius: 12px;
  border: 2px solid #27324a;
}

.jc-counter-section h3 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: #e8f0fe;
}

.jc-counter-display {
  font-size: 4rem;
  font-weight: bold;
  margin: 1.5rem 0;
  color: #ffffff;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.jc-tracker-btn {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.25rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.beer-btn {
  background: linear-gradient(135deg, #f4a261 0%, #e76f51 100%);
  color: #fff;
  box-shadow: 0 4px 6px rgba(231, 111, 81, 0.3);
}

.beer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(231, 111, 81, 0.4);
}

.beer-btn:active {
  transform: translateY(0);
}

.cosmo-btn {
  background: linear-gradient(135deg, #e07a5f 0%, #d62828 100%);
  color: #fff;
  box-shadow: 0 4px 6px rgba(214, 40, 40, 0.3);
}

.cosmo-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(214, 40, 40, 0.4);
}

.cosmo-btn:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .jc-tracker-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem;
  }
  
  .jc-counter-display {
    font-size: 3rem;
  }
}
