/* CSS Custom Properties */
:root {
  --page-bg: #F5F5F2;
  --header-bg: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --accent: #2563EB;
  --reset-red: #EF4444;
  --check-green: #22C55E;
  --border: #E5E5E5;
  --tile-bg: #FFFFFF;
  --tile-text: #1A1A1A;
  --ad-bg: #EEEEED;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--page-bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* Visually Hidden (SEO) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 16px 24px;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  height: 110px;
}

.header-logo {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
}

.header-logo .logo-banner {
  display: block;
}

.header-logo .logo-mobile {
  display: none;
}

.header-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
}

.counter {
  line-height: 1;
}

.counter-value {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.counter-total {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-bar {
  width: 120px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.35s ease;
}

.reset-btn {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 2px;
  transition: border-color 0.15s, color 0.15s;
}

.reset-btn:hover {
  border-color: var(--reset-red);
  color: var(--reset-red);
}

.reset-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Ad Slots */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ad-bg);
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-banner {
  max-width: 728px;
  height: 90px;
  margin: 16px auto;
}

.ad-rectangle {
  width: 300px;
  height: 250px;
}

.ad-placeholder {
  opacity: 0.6;
}

/* Main Content Layout */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
}

.sidebar {
  order: 2;
}

.game-area {
  order: 1;
}

.mobile-ad {
  display: none;
}

/* How to Play */
.how-to-play {
  background: var(--header-bg);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.how-to-play h2 {
  margin: 0 0 12px;
  font-size: 1.125rem;
  color: var(--text-primary);
}

.how-to-play p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* Letter Grid */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}

/* Letter Tile */
.letter-tile {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--tile-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  user-select: none;
}

.letter-tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.letter-tile:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.letter-tile.spotted {
  filter: grayscale(1);
  opacity: 0.32;
}

.letter-tile.spotted:hover {
  opacity: 0.5;
}

.tile-letter {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--tile-text);
  line-height: 1;
}

.tile-example {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 6px;
  text-align: center;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--check-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.letter-tile.spotted .tile-check {
  opacity: 1;
  transform: scale(1);
}

.tile-check svg {
  width: 14px;
  height: 14px;
  color: white;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--header-bg);
  padding: 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.modal p {
  margin: 0 0 24px;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.modal-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.modal-btn-cancel {
  background: var(--border);
  color: var(--text-primary);
}

.modal-btn-cancel:hover {
  background: #D4D4D4;
}

.modal-btn-confirm {
  background: var(--reset-red);
  color: white;
}

.modal-btn-confirm:hover {
  background: #DC2626;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

.footer p {
  margin: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 1;
  }

  .sidebar .ad-rectangle {
    display: none;
  }

  .game-area {
    order: 2;
  }

  .mobile-ad {
    display: flex;
    justify-content: center;
    order: 3;
    margin-top: 16px;
  }
}

@media (max-width: 640px) {
  .header-logo .logo-banner {
    display: none;
  }

  .header-logo .logo-mobile {
    display: block;
  }

  .header-inner {
    height: 90px;
  }

  .counter-value {
    font-size: 1.8rem;
  }

  .progress-bar {
    width: 90px;
  }

  .letter-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }

  .tile-letter {
    font-size: 2rem;
  }

  .ad-banner {
    height: 60px;
  }
}

@media (max-width: 400px) {
  .header {
    padding: 12px 16px;
  }

  .letter-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
  }

  .tile-letter {
    font-size: 1.75rem;
  }

  .tile-example {
    font-size: 0.625rem;
  }

  .tile-check {
    width: 20px;
    height: 20px;
    top: 4px;
    right: 4px;
  }

  .tile-check svg {
    width: 12px;
    height: 12px;
  }
}
