@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Space+Grotesk:wght@600;700&display=swap');

:root {
  /* Permanent Black & Gold Base */
  --paper: #0c0d10;
  --paper-dim: #1e2229;
  --modal-bg: #14171d;
  --ink: #f5f5f7;
  --ink-soft: #8e95a5;
  
  /* Accents & States */
  --stamp-green: #3f7547;       /* Correct Position: Classic Wordle Green */
  --gold-primary: #d4af37;      /* Metallic Gold UI Accent */
  --gold-present: #c79a2b;      /* Wrong Position: Classic Gold */
  --tile-absent: #1e222a;       /* Charcoal Grey */
  
  --line: #2d333f;
  --error: #e05244;
  --bg-dot: rgba(212, 175, 55, 0.05);

  /* Font & tile scaling */
  --tile-size: 52px;
  --tile-font-size: 24px;
}

/* Font Size Scales */
body.font-large {
  --tile-size: 58px;
  --tile-font-size: 28px;
}

body.font-xlarge {
  --tile-size: 64px;
  --tile-font-size: 32px;
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, var(--bg-dot) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 60px;
}

/* Top Bar Layout */
.top-bar {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.top-spacer {
  width: 36px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--gold-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: #fff;
  background: var(--paper-dim);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--gold-primary);
}

header {
  text-align: center;
  margin-bottom: 20px;
  max-width: 420px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-primary);
}

h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 34px;
  margin: 4px 0 6px;
  letter-spacing: -0.02em;
  color: var(--gold-primary);
}

.sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.5;
}

#board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 22px;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  gap: 6px;
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid var(--line);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: var(--tile-font-size);
  text-transform: uppercase;
  color: var(--ink);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

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

.tile.reveal {
  animation: flip 0.5s ease forwards;
  color: #ffffff;
  border-color: transparent;
}

.tile.correct { 
  background: var(--stamp-green); 
  color: #ffffff;
}

.tile.present { 
  background: var(--gold-present); 
  color: #ffffff;
}

.tile.absent  { 
  background: var(--tile-absent); 
  color: var(--ink-soft);
}

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

@keyframes flip {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(90deg); background: var(--paper); }
  51%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

#message {
  min-height: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold-primary);
  margin-bottom: 14px;
  text-align: center;
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 480px;
}

.krow {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.key {
  font-family: 'Plus Jakarta Sans', sans-serif;
  border: none;
  border-radius: 4px;
  background: var(--paper-dim);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  padding: 0;
  height: 46px;
  min-width: 32px;
  flex: 1;
  max-width: 42px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.key:active {
  transform: scale(0.94);
}

.key.wide {
  max-width: 62px;
  font-size: 11px;
}

.key.correct { 
  background: var(--stamp-green); 
  color: #ffffff; 
}

.key.present { 
  background: var(--gold-present); 
  color: #ffffff; 
}

.key.absent  { 
  background: var(--tile-absent); 
  color: var(--ink-soft); 
}

.key:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 2px;
}

/* Result Screen */
#result {
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  text-align: center;
  margin-top: 20px;
  max-width: 360px;
  width: 100%;
  border-top: 1px dashed var(--line);
  padding-top: 18px;
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.45s ease;
}

#result.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#result h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--gold-primary);
}

#shareGrid {
  font-size: 16px;
  line-height: 1.3;
  white-space: pre;
  margin: 12px 0 16px;
}

.btn-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.btn {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 18px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.96);
}

.primary-btn {
  background: var(--gold-primary);
  color: #0c0d10;
  border: none;
}

.secondary-btn {
  background: var(--paper-dim);
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary-btn:hover {
  border-color: var(--gold-primary);
}

.btn:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 2px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}

.stats b {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-primary);
  font-family: 'Space Grotesk', sans-serif;
}

/* Modal */
.modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  background: transparent;
  max-width: 400px;
  width: 90%;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--modal-bg);
  color: var(--ink);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.modal-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  margin: 0;
  font-size: 20px;
  color: var(--gold-primary);
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.setting-text {
  padding-right: 16px;
}

.setting-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.setting-desc {
  font-size: 12px;
  color: var(--ink-soft);
}

.setting-select {
  background: var(--paper-dim);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--paper-dim);
  border: 1px solid var(--line);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--ink-soft);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--gold-primary);
  border-color: var(--gold-primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #0c0d10;
}