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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: #fafafa;
  color: #262626;
  min-height: 100svh;
  display: flex;
  justify-content: center;
}

.green {
  color: #22c55e;
}

.container {
  width: 100%;
  max-width: 420px;
  padding: 16px;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  text-align: center;
  margin-bottom: 24px;
  width: 100%;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.lang-toggle {
  position: absolute;
  left: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.lang-active {
  color: #262626;
  font-weight: 700;
}

.lang-option {
  color: #a3a3a3;
  text-decoration: none;
  transition: color 0.1s;
}

.lang-option:active {
  color: #262626;
}

.lang-sep {
  color: #d4d4d4;
}

.info-link {
  position: absolute;
  right: 0;
  width: 28px;
  height: 28px;
  border: 2px solid #d4d4d4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  font-style: italic;
  color: #737373;
  text-decoration: none;
  transition: border-color 0.1s;
}

.info-link:active {
  border-color: #a3a3a3;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #262626;
}

.title-link {
  text-decoration: none;
  color: inherit;
}

.date {
  font-size: 14px;
  color: #737373;
  margin-top: 4px;
}

.today-banner {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #3b82f6;
  text-decoration: none;
}

.nav-chevron {
  color: #737373;
  text-decoration: none;
  font-size: 18px;
  padding: 0 8px;
  transition: color 0.1s;
}

.nav-chevron:active {
  color: #262626;
}

/* Info page */
.info-page main {
  padding-top: 48px;
  align-items: flex-start;
}

.info-page h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.instructions {
  list-style: disc;
  padding-left: 20px;
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-page footer {
  padding-top: 24px;
  font-size: 13px;
  color: #737373;
}

.info-page footer a {
  color: #262626;
}

main {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 24px;
}

/* Letter buttons */
.letters {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.letter {
  width: 52px;
  height: 52px;
  border: 2px solid #d4d4d4;
  border-radius: 2px;
  background: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s;
}

.letter:active {
  background: #f5f5f5;
}

.letter.center {
  border-color: #22c55e;
  color: #22c55e;
  width: 60px;
  height: 60px;
  font-size: 24px;
}

.other-letters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Current word display */
.word-feedback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.current-word {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  min-height: 40px;
  line-height: 40px;
  text-transform: uppercase;
  text-align: center;
  position: relative;
  display: inline-block;
}

.current-word .center-letter {
  color: #22c55e;
}

.unlock-message {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  color: #737373;
}

.unlock-message .unlock-title {
  color: #22c55e;
  font-weight: 700;
}

.word-badge {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  margin-left: 8px;
}

.word-badge.success {
  color: #22c55e;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 12px 24px;
  border: 2px solid #d4d4d4;
  border-radius: 2px;
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-width: 100px;
  min-height: 44px;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s;
}

.btn:active {
  background: #f5f5f5;
}

.btn-primary {
  background: #262626;
  color: #fff;
  border-color: #262626;
}

.btn-primary:active {
  background: #404040;
}

/* Feedback */
.feedback {
  font-size: 14px;
  font-weight: 600;
  min-height: 20px;
  text-align: center;
  transition: opacity 0.3s;
}

.feedback.error {
  color: #ef4444;
}

.feedback.success {
  color: #22c55e;
}

.feedback.uncommon {
  color: #3b82f6;
}

.feedback.rare {
  color: #a855f7;
}

.feedback.legendary {
  color: #f59e0b;
}

/* Rarity breakdown */
.rarity-breakdown {
  font-size: 12px;
  color: #737373;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.rarity-breakdown .tier {
  white-space: nowrap;
}

.rarity-breakdown .tier.uncommon {
  color: #3b82f6;
}

.rarity-breakdown .tier.rare {
  color: #a855f7;
}

.rarity-breakdown .tier.legendary {
  color: #f59e0b;
}

.rarity-breakdown .tier.bloom {
  color: #22c55e;
}

.rarity-breakdown .locked-hint {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #a3a3a3;
  font-size: 12px;
}

.lock-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Found words */
.found-words {
  width: 100%;
  border: 1px solid #d4d4d4;
  border-radius: 2px;
  padding: 12px;
}

.found-words h2 {
  font-size: 14px;
  font-weight: 600;
  color: #737373;
  margin-bottom: 8px;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.word-list .word {
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  background: #f5f5f5;
  border-radius: 2px;
  text-transform: uppercase;
}

.word-list .word.bloom {
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #22c55e;
}

.word-list .word.uncommon {
  background: #eff6ff;
  color: #3b82f6;
}

.word-list .word.rare {
  background: #faf5ff;
  color: #a855f7;
}

.word-list .word.legendary {
  background: #fffbeb;
  color: #f59e0b;
}

/* Share button */
.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid #d4d4d4;
  border-radius: 2px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  color: #737373;
  cursor: pointer;
}

.share-btn:active {
  background: #f5f5f5;
}

.share-btn svg {
  width: 16px;
  height: 16px;
}

/* Give up button */
.give-up-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid #e5e5e5;
  border-radius: 2px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  color: #a3a3a3;
  cursor: pointer;
}

.give-up-btn:active {
  background: #f5f5f5;
}

/* Possible words (revealed after give up) */
.possible-words {
  width: 100%;
  border: 1px solid #d4d4d4;
  border-radius: 2px;
  padding: 12px;
}

.possible-words h2 {
  font-size: 14px;
  font-weight: 600;
  color: #737373;
  margin-bottom: 8px;
}

/* Phase 2 unlock animation */
@keyframes unlock {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.phase2-unlocked {
  animation: unlock 0.4s ease-out;
}

/* Progress bar */
.progress {
  width: 100%;
}

.progress-bar {
  width: 100%;
  height: 20px;
  background: #fff;
  border: 1px solid #d4d4d4;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: #22c55e;
  border-radius: 10px;
  transition: width 0.3s, background 0.3s;
}

.progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #555;
  z-index: 1;
  transition: color 0.3s, opacity 0.2s;
}

.progress-bar.completed .progress-label {
  color: #fff;
  letter-spacing: 2px;
}

/* Bottom actions */
.bottom-pinned {
  margin-top: auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
}

.bottom-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 20px;
}

/* Animations */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.3s;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.pop {
  animation: pop 0.2s;
}

/* Error page (404) */
.error-page {
  justify-content: center;
  padding-bottom: 80px;
}

.error-letters {
  display: flex;
  gap: 8px;
}

.error-letters .letter.center {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.error-message {
  font-size: 16px;
  color: #737373;
  margin-bottom: 12px;
}

.error-page .btn {
  text-decoration: none;
}

.error-page .btn::after {
  content: " →";
}

/* Puzzle archive on 404 page */
.puzzle-archive {
  width: 100%;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid #e5e5e5;
}

.puzzle-archive h2 {
  font-size: 18px;
  font-weight: 700;
  color: #262626;
  margin-bottom: 16px;
  text-align: center;
}

/* CSS-only tabs */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.tab-input {
  display: none;
}

.tab-label {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #737373;
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid #e5e5e5;
  transition: color 0.15s, border-color 0.15s;
}

.tab-label:hover {
  color: #262626;
}

.tab-input:checked + .tab-label {
  color: #22c55e;
  border-bottom-color: #22c55e;
}

.tab-content {
  display: none;
  grid-column: 1 / -1;
  padding-top: 16px;
}

/* Show content when corresponding radio is checked */
#tab-en:checked ~ #content-en,
#tab-es:checked ~ #content-es {
  display: block;
}

/* Puzzle list grid */
.puzzle-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 400px) {
  .puzzle-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 600px) {
  .puzzle-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

.puzzle-link {
  display: block;
  padding: 8px 12px;
  font-family: monospace;
  font-size: 14px;
  color: #262626;
  text-decoration: none;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  text-align: center;
}

.puzzle-link:hover {
  border-color: #22c55e;
  color: #22c55e;
}
