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

/* Fluid sizing for all screens */
:root {
  --node: clamp(6px, 1.2vmin, 10px);
  --dot: var(--node);
  --line: var(--node);
  --cell: clamp(22px, 6vmin, 48px);
  --gap: 0px;
  --game-padding: clamp(8px, 2vmin, 16px);
  --bg-1: #f7f4ff;
  --bg-2: #e8f4ff;
  --panel: rgba(255, 255, 255, 0.7);
  --panel-border: rgba(70, 110, 180, 0.18);
  --text: #243449;
  --muted: #4a5a6b;
  --accent: #5a8bff;
  --accent-2: #8dd3ff;
  --line-hover: linear-gradient(to bottom, #7bb8ff, #a6d8ff);
  --line-hover-color: rgba(90, 139, 255, 0.45);
  --line-idle: rgba(130, 170, 220, 0.7);
  --dot-color: #1e2a36;
  --box-bg: rgba(255, 255, 255, 0.5);
  --shadow: 0 10px 30px rgba(31, 38, 135, 0.2);
}

[data-theme="dark"] {
  --bg-1: #0b0f1a;
  --bg-2: #141a2c;
  --panel: rgba(8, 12, 22, 0.75);
  --panel-border: rgba(80, 255, 238, 0.25);
  --text: #e6f4ff;
  --muted: #9fb3c8;
  --accent: #16f2ff;
  --accent-2: #8b5cff;
  --line-hover: linear-gradient(to bottom, #16f2ff, #6a5cff);
  --line-hover-color: rgba(22, 242, 255, 0.45);
  --line-idle: rgba(120, 210, 255, 0.35);
  --dot-color: #8be9ff;
  --box-bg: rgba(12, 20, 36, 0.9);
  --shadow: 0 12px 34px rgba(10, 15, 35, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-1: #0b0f1a;
    --bg-2: #141a2c;
    --panel: rgba(8, 12, 22, 0.75);
    --panel-border: rgba(80, 255, 238, 0.25);
    --text: #e6f4ff;
    --muted: #9fb3c8;
    --accent: #16f2ff;
    --accent-2: #8b5cff;
    --line-hover: linear-gradient(to bottom, #16f2ff, #6a5cff);
    --line-hover-color: rgba(22, 242, 255, 0.45);
    --line-idle: rgba(120, 210, 255, 0.35);
    --dot-color: #8be9ff;
    --box-bg: rgba(12, 20, 36, 0.9);
    --shadow: 0 12px 34px rgba(10, 15, 35, 0.6);
  }
}

/* Soft Background */
body {
  font-family: "Arial", sans-serif;
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: 100vh;
  margin: 0;
  padding: clamp(8px, 2vmin, 20px);
  overflow: auto;
  background: radial-gradient(
      1000px 500px at 10% 10%,
      var(--bg-2),
      transparent 55%
    ),
    radial-gradient(900px 600px at 90% 20%, var(--bg-2), transparent 60%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text);
}

.nav-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vmin, 16px);
  padding: clamp(6px, 1.4vmin, 10px) clamp(8px, 2vmin, 16px);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.nav-title {
  font-weight: 700;
  font-size: clamp(0.9rem, 2vmin, 1.1rem);
  color: var(--text);
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(6px, 1.6vmin, 10px);
  align-items: center;
  justify-content: flex-end;
}

.nav-button {
  border-radius: 999px;
  padding: clamp(6px, 1.4vmin, 10px) clamp(10px, 2vmin, 16px);
  font-size: clamp(0.7rem, 1.6vmin, 0.85rem);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0f18;
  white-space: nowrap;
}

.qr-panel {
  position: fixed;
  top: clamp(72px, 10vmin, 120px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(320px, 90vw);
  padding: 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  display: none;
  gap: 10px;
  text-align: center;
}

.qr-panel.open {
  display: grid;
  place-items: center;
}

.qr-title {
  font-weight: 600;
  color: var(--text);
}

.qr-url {
  font-size: 0.65rem;
  color: var(--muted);
  word-break: break-all;
}

.qr-image {
  width: 160px;
  height: 160px;
  border-radius: 8px;
  background: #ffffff;
  padding: 6px;
}
/* Game Container */
#game {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  padding: var(--game-padding);
  max-width: min(100vw, 1600px);
  width: 100%;
  min-height: calc(100vh - clamp(16px, 4vmin, 40px));
  margin: 0;
  gap: clamp(6px, 1.6vmin, 12px);
  position: relative;
}

/* Header Styling */
#header {
  text-align: center;
  margin-bottom: 6px;
}

#header h1 {
  font-size: clamp(1.2rem, 2.8vmin, 2rem);
  color: var(--text);
}

#header p {
  color: var(--muted);
  margin: 5px 0;
  font-size: clamp(0.75rem, 1.6vmin, 1rem);
}

#header select {
  font-size: clamp(0.75rem, 1.4vmin, 0.9rem);
}

.name-accordion {
  width: 100%;
  max-width: 720px;
  margin: clamp(4px, 1vmin, 10px) 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  border: 1px solid var(--panel-border);
  padding: clamp(6px, 1.2vmin, 10px);
}

.name-accordion summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

.name-accordion summary::-webkit-details-marker {
  display: none;
}

.name-accordion summary::after {
  content: "▾";
  float: right;
  transition: transform 0.2s ease;
}

.name-accordion[open] summary::after {
  transform: rotate(180deg);
}

.turn-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2px, 0.8vmin, 6px);
  margin: clamp(2px, 0.8vmin, 6px) 0;
}

.turn-current {
  font-size: clamp(0.95rem, 2.2vmin, 1.3rem);
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 12px color-mix(in srgb, var(--accent) 40%, transparent);
}

.turn-next {
  font-size: clamp(0.75rem, 1.6vmin, 0.95rem);
  color: var(--muted);
}

.name-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(6px, 1.4vmin, 10px);
  margin-top: clamp(4px, 1vmin, 10px);
  width: 100%;
  max-width: 720px;
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: clamp(0.7rem, 1.4vmin, 0.85rem);
  color: var(--muted);
}

.name-field input {
  padding: clamp(6px, 1.4vmin, 10px);
  border-radius: 8px;
  border: 1px solid rgba(120, 150, 200, 0.45);
  background: rgba(255, 255, 255, 0.95);
  color: #1f2a3a;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.name-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.name-field input:disabled {
  opacity: 0.75;
}

body[data-theme="dark"] .name-field input,
body:not([data-theme="light"]) .name-field input {
  border-color: rgba(120, 210, 255, 0.35);
  background: rgba(10, 18, 32, 0.9);
  color: #e6f4ff;
}

/* Board */
#board {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  gap: var(--gap);
  flex: 1;
  justify-content: center;
}

/* Row */
.row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--gap);
}

/* Dot */
.dot {
  height: var(--dot);
  width: var(--dot);
  background-color: var(--dot-color);
  border-radius: 999px;
}

/* Horizontal Line */
.horizContainer {
  height: var(--line);
  width: var(--cell);
  border-radius: 999px;
  transition: background 0.2s ease;
}

/* Vertical Line */
.vertContainer {
  height: var(--cell);
  width: var(--line);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.line-claimed {
  box-shadow: none;
}

body[data-theme="dark"] .line-claimed {
  box-shadow: 0 0 8px currentColor, 0 0 16px currentColor;
}

/* Box */
.box {
  height: var(--cell);
  width: var(--cell);
  background: var(--box-bg);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.box-claimed {
  animation: box-pop 420ms ease-out;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

@keyframes box-pop {
  0% {
    transform: scale(0.85);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  60% {
    transform: scale(1.05);
    box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .box-claimed {
    animation: none;
  }
}

/* Hover Effect */
.horizContainer:hover,
.vertContainer:hover {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* Buttons */
button {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: white;
  border: none;
  border-radius: 6px;
  padding: clamp(4px, 1.2vmin, 8px) clamp(8px, 2.2vmin, 15px);
  margin: clamp(3px, 1vmin, 5px);
  cursor: pointer;
  font-size: clamp(0.7rem, 1.6vmin, 0.9rem);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

button:hover {
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}
 /* Player Score Section */
.main-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.6vmin, 12px);
  width: 100%;
  flex: 1;
  justify-content: center;
}

.scores-area {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: clamp(6px, 1.6vmin, 12px);
  width: 100%;
  max-width: 900px;
  justify-content: center;
}

.player-score {
  /* flex: 1 1 45%; Each player takes up 45% width to create two columns */
  flex: 1 1 120px;
  padding: clamp(3px, 0.8vmin, 6px);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Highlight the Current Player */
.active-player {
  border: 3px solid var(--accent);
  background-color: color-mix(in srgb, var(--accent) 25%, transparent);
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  font-size: clamp(0.9rem, 2vmin, 1.1rem);
}

/* Board Buttons Styling */
#board-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(4px, 1.2vmin, 8px);
  margin-top: clamp(4px, 1.2vmin, 8px);
}
button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#game.is-playing:not(.show-controls) #header h1,
#game.is-playing:not(.show-controls) .turn-panel,
#game.is-playing:not(.show-controls) .name-accordion,
#game.is-playing:not(.show-controls) #board-buttons,
#game.is-playing:not(.show-controls) #header p,
#game.is-playing:not(.show-controls) #header select,
#game.is-playing:not(.show-controls) #winner {
  display: none;
}

@media (orientation: landscape) {
  :root {
    --cell: clamp(26px, 6.2vmax, 64px);
    --node: clamp(6px, 1.4vmax, 12px);
    --line: var(--node);
    --dot: var(--node);
    --gap: 0px;
  }

  body {
    padding: 0;
  }

  #game {
    width: 100vw;
    max-width: 100vw;
    min-height: 100vh;
    border-radius: 0;
  }

  .scores-area {
    max-width: 1100px;
  }
}

@media (max-width: 800px) and (orientation: portrait) {
  .nav-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-actions {
    justify-content: flex-start;
  }

  .scores-area {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    max-width: 100%;
  }

  .player-score {
    font-size: 0.08rem;
    padding: 1px;
    border-radius: 2px;
    line-height: 1;
  }
}
