* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1b1b1f;
  color: #eee;
  margin: 0;
  padding: 24px 16px 64px;
}

#app { max-width: 480px; margin: 0 auto; text-align: center; }

.header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  position: relative;
}

h1 { font-size: 22px; margin: 0; }

.how-to-play {
  position: absolute;
  right: 0;
  background: none;
  border: 1px solid #444;
  color: #aac8ff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.how-to-play:hover { background: #24242b; }

.mode-picker {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mode-picker button {
  background: #2a2a30;
  color: #ccc;
  border: 1px solid #444;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.mode-picker button.active {
  background: #4a8cff;
  border-color: #4a8cff;
  color: #fff;
  font-weight: 600;
}

.timer {
  font-size: 15px;
  font-weight: 600;
  color: #aac8ff;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.objective {
  font-size: 14px;
  color: #ccc;
  background: #24242b;
  border: 1px solid #3a3a42;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 20px;
  line-height: 1.5;
}

.objective strong { color: #fff; }

.grid {
  display: inline-grid;
  gap: 4px;
  background: #000;
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.cell {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-radius: 5px;
  background: #232329;
  color: #666;
  border: 2px solid transparent;
  margin: 0;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
}

.cell.given { background: #2f2f37; color: #fff; cursor: default; }
.cell.fillable { background: #1a1a1f; color: #7fb2ff; cursor: pointer; }
.cell.fillable:hover { background: #23232b; }
.cell.selected { border-color: #4a8cff; }
.cell.line-ok { background: #163a24; color: #7ee2a0; }
.cell.line-error { background: #3a1616; color: #ff9d9d; }
.cell.given.line-ok { background: #1c4a2e; }
.cell.given.line-error { background: #4a1c1c; }

.numpad {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.numpad button {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #2a2a30;
  color: #eee;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.numpad button:disabled {
  opacity: 0.25;
  cursor: default;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.actions button {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.actions button:hover { background: #444; }

.win-banner {
  background: #163a24;
  border: 1px solid #2f7a4e;
  color: #7ee2a0;
  padding: 14px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 12px;
}

.win-banner[hidden] { display: none; }

.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.tutorial-overlay[hidden] { display: none; }

.tutorial-panel {
  background: #1e1e24;
  border: 1px solid #3a3a42;
  border-radius: 12px;
  padding: 28px 24px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  position: relative;
}

.tutorial-panel h2 { margin: 0 0 14px; font-size: 18px; }

.tutorial-text {
  font-size: 15px;
  line-height: 1.5;
  color: #eee;
  margin: 0 0 8px;
}

.tutorial-hint {
  font-size: 12px;
  color: #999;
  margin: 0 0 16px;
}

.tutorial-hint[hidden] { display: none; }

.tutorial-panel .grid { margin: 16px auto; }
.tutorial-panel .numpad { margin-bottom: 16px; }

.tutorial-skip {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: #888;
  font-size: 12px;
  cursor: pointer;
}

.tutorial-advance {
  background: #4a8cff;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tutorial-advance[hidden] { display: none; }

.cell.tutorial-target {
  animation: tutorial-pulse 1.4s ease-in-out infinite;
}

@keyframes tutorial-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 140, 255, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(74, 140, 255, 0); }
}

/* Ad banner */
.ad-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.ad-banner-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  max-width: 480px;
  margin: 0 auto;
}

.ad-placeholder {
  flex: 1;
  height: 50px;
  background: #f3f4f6;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-label {
  font-size: 10px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.remove-ads-btn {
  flex-shrink: 0;
  background: #4a8cff;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.remove-ads-btn:active { opacity: 0.8; }

#app { padding-bottom: 72px; }
