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

body {
  font-family: system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: #f5f5f5;
}

#main {
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

h1 {
  margin-bottom: 10px;
}

#status {
  font-size: 1.2em;
  margin: 10px 0;
  min-height: 1.5em;
  font-weight: bold;
}

#board {
  border-collapse: collapse;
}

#board td {
  width: 52px;
  height: 52px;
  text-align: center;
  vertical-align: middle;
  font-size: 1.5em;
  font-weight: bold;
  border: 1px solid #999;
  cursor: pointer;
  user-select: none;
}

#board td:hover {
  background: #e8e8e8;
}

#board td.filled:hover {
  background: transparent;
  cursor: default;
}

/* Thick borders for 3x3 blocks */
#board td:nth-child(3n) {
  border-right: 3px solid #333;
}

#board td:nth-child(3n+1) {
  border-left: 3px solid #333;
}

#board tr:nth-child(3n) td {
  border-bottom: 3px solid #333;
}

#board tr:nth-child(3n+1) td {
  border-top: 3px solid #333;
}

/* Colors */
.gold {
  color: #b8860b;
}

.blue {
  color: #1a5fb4;
}

.red {
  color: #c01c28;
}

/* Digit picker */
#picker-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

#picker {
  display: none;
  position: absolute;
  z-index: 20;
  background: white;
  border: 2px solid #333;
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#picker button {
  width: 40px;
  height: 40px;
  font-size: 1.2em;
  font-weight: bold;
  margin: 2px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
}

#picker button:hover {
  background: #ddd;
}

#new-game {
  margin-top: 15px;
  padding: 10px 24px;
  font-size: 1em;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid #999;
}

#theme-toggle {
  padding: 8px 12px;
  font-size: 1em;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid #999;
  background: #fff;
}

#mode-select {
  margin: 10px 0;
  font-size: 1em;
}

#mode-select label {
  font-weight: bold;
  margin-right: 6px;
}

#mode-select select {
  padding: 4px 8px;
  font-size: 1em;
  border-radius: 4px;
  border: 1px solid #999;
}

#score-detail {
  margin-top: 10px;
  font-size: 0.9em;
  color: #555;
  min-height: 1.2em;
}

#rules {
  width: 240px;
  font-size: 0.85em;
  color: #444;
  line-height: 1.5;
}

#rules h2 {
  font-size: 1.1em;
  margin-bottom: 8px;
  color: #333;
}

#rules h3 {
  margin-top: 10px;
  margin-bottom: 4px;
  color: #333;
  font-size: 0.95em;
}

#rules ul {
  margin-left: 18px;
  margin-bottom: 4px;
}

#rules p {
  margin-bottom: 4px;
}

/* Mobile responsive */
@media (max-width: 540px) {
  body {
    padding: 12px;
  }

  #main {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }

  #board td {
    width: calc((100vw - 32px) / 9);
    height: calc((100vw - 32px) / 9);
    font-size: 1.2em;
  }

  #picker {
    left: 50% !important;
    transform: translateX(-50%);
  }

  #picker button {
    width: 36px;
    height: 36px;
    font-size: 1.1em;
  }

  #rules {
    width: auto;
    max-width: 100%;
  }

  #new-game {
    width: 100%;
  }
}
