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

body {
  background: #000;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  height: 100vh;
  padding: 10px 20px 0 20px;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 540px;
  height: 100%;
}

.hidden { display: none !important; }

#game-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#bottom-space {
  margin-top: 15px;
  margin-bottom: 5px;
  display: flex;
  justify-content: flex-start;
  padding: 0 1px;
}



#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 40px;
  margin: 10px 0;
  padding: 0 1px;
}


#meta-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  width: 100%;
  aspect-ratio: 1;
  background: transparent;
  border-radius: 8px;
  padding: 1px;
}

.small-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  background: #000;
  border-radius: 4px;
  padding: 2px;
  position: relative;
  transition: box-shadow 0.15s;
  border: 1px solid #333;
  outline: 1px solid #333;
}

.small-board.active {
  border: 1px solid transparent;
  outline: 1px solid #e89830;
}

.small-board.meta-winner {
  border: 1px solid #888;
  outline: 1px solid #888;
}

/* Win-line markers */
.cell.draw-marker::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15%;
  height: 15%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: white;
  pointer-events: none;
  z-index: 1;
}

.cell {
  background: #333;
  border-radius: 3px;
  position: relative;
  cursor: default;
  transition: background 0.1s;
}

.cell.blue {
  background: #4a9d5b;
  border-radius: 8px;
}

.cell.red {
  background: #d94a4a;
  border-radius: 8px;
}

.cell.dimmed {
  opacity: 0.5;
}

.cell.blue.dimmed {
  background: #5ab86b;
}

.cell.half-dimmed {
  opacity: 0.75;
}

.cell.legal {
  cursor: pointer;
}

.cell.legal:hover {
  border: 1px solid #e89830;
  opacity: 1;
}

.cell.hint {
  outline: 2px solid #4a9d5b;
  outline-offset: -2px;
  z-index: 1;
}

.cell.hint::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20%;
  height: 20%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: white;
  pointer-events: none;
  z-index: 1;
}

/* Last-move marker */
.cell.last-move::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30%;
  height: 30%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid white;
  pointer-events: none;
}


#level, #player-name, #undo, #continue-btn, #hint {
  padding: 6px 20px;
  font-size: 0.9rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #000;
  color: #4a9d5b;
  cursor: pointer;
  transition: border-color 0.15s;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#level:hover, #player-name:hover, #undo:hover, #continue-btn:hover, #hint:hover,
#level:active, #player-name:active, #undo:active, #continue-btn:active, #hint:active {
  border-color: #4a9d5b;
}

#level, #player-name, #undo, #continue-btn, #hint {
  width: calc((100% - 10px) / 3);
  padding: 6px 0;
}

#continue-btn {
  margin: 0 auto;
}

#hint {
  margin-left: auto;
}

.btn-hidden {
  display: none;
}

/* Players view */
#players-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 40px;
}

#players-header {
  font-size: 1.2rem;
  color: #888;
}

#players-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  display: flex;
  align-items: center;
  padding: 5px 16px;
  background: #1a1a1a;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.player-row:hover {
  background: #2a2a2a;
}

.player-row-name {
  color: #4a9d5b;
  font-size: 1rem;
  flex: 1;
}

.player-row-info {
  color: #666;
  font-size: 0.8rem;
  flex: 1;
  text-align: center;
}

.player-row-clear {
  padding: 10px 28px;
  font-size: 1rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #000;
  color: #4a9d5b;
  cursor: pointer;
  transition: border-color 0.15s;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.player-row-clear:hover {
  border-color: #4a9d5b;
}

.player-row-action {
  padding: 10px 12px;
  font-size: 0.8rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #000;
  color: #666;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  margin-left: 4px;
}

.player-row-action:hover {
  border-color: #4a9d5b;
  color: #4a9d5b;
}

#new-player-btn {
  padding: 10px 28px;
  font-size: 1rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #000;
  color: #4a9d5b;
  cursor: pointer;
  transition: border-color 0.15s;
  margin-top: 8px;
}

#new-player-btn:hover {
  border-color: #4a9d5b;
}

#rules {
  width: 100%;
  margin-top: 24px;
}

#rules-header {
  font-size: 1.2rem;
  color: #888;
  text-align: center;
  margin-bottom: 12px;
}

#rules ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#rules li {
  color: #666;
  font-size: 1rem;
  padding-left: 12px;
}

#hint-text {
  text-align: center;
  font-size: 0.85rem;
  color: #4a9d5b;
  margin-top: 8px;
  min-height: 1.2em;
}
