/* Word Guess Daily - Stylesheet */

:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #273549;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;

  --correct: #10b981;
  --present: #eab308;
  --absent: #475569;

  --tile-empty-bg: transparent;
  --tile-border: #475569;
  --tile-active-border: #94a3b8;
  --key-bg: #334155;
  --key-hover: #475569;

  --radius: 8px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* --- Header --- */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s ease;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
}

.back-link:hover, .back-link:focus-visible {
  color: var(--correct);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-icon {
  font-size: 1.5rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-button {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 1.15rem;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.icon-button:hover, .icon-button:focus-visible {
  background: var(--border);
  border-color: var(--correct);
  outline: 2px solid var(--correct);
  outline-offset: 2px;
}

/* --- Main Game Container --- */
.game-container {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-header-text {
  text-align: center;
  margin-bottom: 1rem;
}

.game-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.game-subtitle {
  color: var(--text-muted);
  font-size: 0.925rem;
  max-width: 520px;
  margin: 0 auto;
}

/* Mode Bar */
.mode-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mode-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s ease;
}

.mode-pill.active {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* Toast notification */
.toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background-color: #ffffff;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  animation: toast-fade 0.2s ease-out;
}

@keyframes toast-fade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Word Board 6x5 Grid --- */
.board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.5rem;
  width: 100%;
}

.word-grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 5 / 6;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.grid-row.shake {
  animation: shake-row 0.5s ease-in-out;
}

@keyframes shake-row {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--tile-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 800;
  text-transform: uppercase;
  user-select: none;
  background-color: var(--tile-empty-bg);
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.tile.active {
  border-color: var(--tile-active-border);
  animation: pop-tile 0.1s ease;
}

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

.tile.flip {
  animation: flip-tile 0.5s ease forwards;
}

@keyframes flip-tile {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

.tile.correct {
  background-color: var(--correct) !important;
  border-color: var(--correct) !important;
  color: #ffffff;
}

.tile.present {
  background-color: var(--present) !important;
  border-color: var(--present) !important;
  color: #ffffff;
}

.tile.absent {
  background-color: var(--absent) !important;
  border-color: var(--absent) !important;
  color: #ffffff;
}

.tile.bounce {
  animation: bounce-tile 0.5s ease;
}

@keyframes bounce-tile {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

/* --- Virtual Keyboard --- */
.keyboard {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

.key-btn {
  flex: 1;
  height: 52px;
  background-color: var(--key-bg);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-transform: uppercase;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.key-btn:active {
  transform: translateY(2px);
}

.key-btn.wide-key {
  flex: 1.5;
  font-size: 0.85rem;
}

.key-btn.correct {
  background-color: var(--correct);
}

.key-btn.present {
  background-color: var(--present);
}

.key-btn.absent {
  background-color: #1e293b;
  color: #64748b;
}

/* --- Stats Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: modal-enter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-badge {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 1.25rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.stat-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-big {
  font-size: 1.65rem;
  font-weight: 800;
  color: #ffffff;
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.solution-box {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--correct);
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.sol-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sol-word {
  color: #ffffff;
  font-size: 1.25rem;
  letter-spacing: 2px;
}

.btn-primary {
  width: 100%;
  background: var(--correct);
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  min-height: 46px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: #059669;
}

/* --- SEO Article Block --- */
.content-block {
  max-width: 680px;
  width: 100%;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article-header {
  margin-bottom: 1.5rem;
}

.article-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.35rem;
}

.freshness-tag {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.article-section {
  margin-bottom: 2rem;
}

.article-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.85rem;
}

.article-section h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #e2e8f0;
  margin: 1.25rem 0 0.6rem;
}

.article-section p {
  color: #cbd5e1;
  margin-bottom: 1rem;
  line-height: 1.7;
}

.rules-list {
  padding-left: 1.25rem;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.rules-list strong {
  color: #ffffff;
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.strategy-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.strategy-card h4 {
  color: var(--correct);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.strategy-card p {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 0;
  line-height: 1.6;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.faq-item[open] {
  border-color: var(--correct);
}

.faq-question {
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 1.25rem;
  color: var(--correct);
}

.faq-item[open] .faq-question::after {
  content: "−";
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: #cbd5e1;
  font-size: 0.925rem;
  line-height: 1.6;
}

.cross-links {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.related-games-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.related-games-list li a {
  color: var(--correct);
  text-decoration: none;
  font-weight: 500;
}

.related-games-list li a:hover {
  text-decoration: underline;
}

/* --- Footer --- */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--correct);
}
