:root {
  --bg: #064e3b;
  --surface: #0f3d30;
  --panel: #135544;
  --line: #1e705b;
  --card-bg: #ffffff;
  --text: #f0fdf4;
  --muted: #a7f3d0;
  --emerald: #10b981;
  --gold: #f59e0b;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Lexend", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

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

header {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  padding: 0.75rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, #10b981, #047857);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.brand h1 {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.brand p {
  font-size: 0.8rem;
  color: var(--muted);
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.controls-bar select {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  cursor: pointer;
  outline: none;
}

.btn-header {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-header:hover {
  background: var(--emerald);
  border-color: var(--emerald);
}

main {
  flex: 1;
  max-width: 940px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Spy Banner */
.spy-banner {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 0.9rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.eye-icon {
  font-size: 2.8rem;
  background: var(--panel);
  border: 2px solid var(--emerald);
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
  animation: eyeBlink 4s infinite;
}

@keyframes eyeBlink {
  0%, 96%, 100% { transform: scaleY(1); }
  98% { transform: scaleY(0.1); }
}

.spy-details {
  flex: 1;
}

.spy-sub {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.spy-main {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
}

.spy-score {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold);
}

/* Board Card */
.game-board-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 22px;
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* Items Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  justify-items: center;
}

.spy-item-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 150px;
  background: #ffffff;
  border: 3px solid #d1fae5;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.spy-item-btn:hover {
  transform: translateY(-4px) scale(1.05);
  border-color: var(--emerald);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.item-emoji {
  font-size: 3rem;
  line-height: 1;
}

.item-caption {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 700;
  color: #064e3b;
  text-align: center;
}

/* Memory Card Flip Mode */
.memory-card {
  perspective: 1000px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.4s;
  transform-style: preserve-3d;
}

.spy-item-btn.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front {
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff;
  font-size: 2.2rem;
  font-weight: 800;
}

.card-back {
  background: #ffffff;
  transform: rotateY(180deg);
  flex-direction: column;
  gap: 0.3rem;
}

.spy-item-btn.matched {
  border-color: var(--gold);
  background: #fefce8;
  opacity: 0.7;
  cursor: default;
}

/* Word Reveal Banner */
.word-reveal {
  background: linear-gradient(135deg, #047857, #064e3b);
  border: 2px solid var(--emerald);
  border-radius: 14px;
  padding: 0.8rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: popIn 0.25s ease-out;
}

@keyframes popIn {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.reveal-pic {
  font-size: 2.8rem;
}

.reveal-ga {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fef08a;
}

.reveal-en {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 78, 59, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border: 3px solid var(--emerald);
  border-radius: 22px;
  padding: 2.2rem 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.modal-card h2 {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  color: #fff;
}

.modal-card p {
  color: var(--muted);
  margin: 0.6rem 0 1.2rem;
}

.badge-award {
  background: var(--panel);
  border: 2px solid var(--gold);
  padding: 0.8rem 1.4rem;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 1.5rem;
}

.modal-btn {
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}
