:root {
  --ink: #1e293b;
  --bg: #f0fdfa;
  --surface: #ffffff;
  --line: #ccfbf1;
  --island-teal: #0d9488;
  --island-dark: #134e4a;
  --island-coral: #f97316;
  --island-amber: #f59e0b;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Lexend", system-ui, sans-serif;
  --shadow: 0 8px 24px rgba(13, 148, 136, 0.08);
  --shadow-hover: 0 16px 36px rgba(13, 148, 136, 0.16);
  --radius-lg: 20px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

header {
  background: var(--island-dark);
  color: #fff;
  padding: 0.9rem 1.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 3px solid #2dd4bf;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-decoration: none;
  color: #fff;
}

.brand-icon {
  font-size: 2.2rem;
  background: rgba(45, 212, 191, 0.2);
  padding: 0.4rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: #99f6e4;
  letter-spacing: -0.01em;
}

.brand p {
  font-size: 0.8rem;
  color: #ccfbf1;
}

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

.tab-pills {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.25rem;
  border-radius: 999px;
  gap: 0.3rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #ccfbf1;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background: #2dd4bf;
  color: #134e4a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-header {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.25);
}

.game-container {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.2rem;
  width: 100%;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-intro {
  margin-bottom: 1.5rem;
}

.section-intro h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--island-dark);
}

.section-desc {
  color: #475569;
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

/* ================== TAB 1: IDIOM EXPLORER (FLIP CARDS) ================== */
.idioms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.5rem;
}

.flip-card {
  background-color: transparent;
  width: 100%;
  height: 220px;
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  border: 2px solid var(--line);
}

.flip-card-front {
  background: #ffffff;
}

.flip-card-back {
  background: #f0fdfa;
  border-color: #2dd4bf;
  transform: rotateY(180deg);
}

.idiom-icon {
  font-size: 2.8rem;
}

.idiom-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--island-dark);
}

.idiom-literal-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #fee2e2;
  color: #dc2626;
  text-transform: uppercase;
}

.flip-hint {
  font-size: 0.78rem;
  color: #64748b;
}

.idiom-fig-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--island-teal);
}

.idiom-meaning {
  font-size: 0.92rem;
  color: #334155;
  line-height: 1.35;
}

.idiom-example {
  font-size: 0.8rem;
  color: #64748b;
  font-style: italic;
}

/* ================== TAB 2: SIMILES & METAPHORS ================== */
.similes-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
}

.simile-rules {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rule-card {
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.rule-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.badge-simile { background: #fef3c7; color: #b45309; }
.badge-metaphor { background: #ede9fe; color: #6d28d9; }

.rule-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0.5rem 0 0.3rem;
  color: #0f172a;
}

.rule-card p {
  font-size: 0.85rem;
  color: #64748b;
}

.builder-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.hud-stat {
  font-weight: 700;
  color: #334155;
}

.hud-stat span {
  color: var(--island-teal);
  font-size: 1.2rem;
}

.builder-stage-card {
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.builder-type-pill {
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: #ccfbf1;
  color: var(--island-dark);
  text-transform: uppercase;
}

.sentence-fill-area {
  background: #f8fafc;
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.fill-blank-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  height: 42px;
  background: #ffffff;
  border: 2px solid #0d9488;
  border-radius: 8px;
  color: #0d9488;
  font-weight: 800;
}

.word-chips-pool {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.word-chip-btn {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 0.6rem 1.2rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--ink);
}

.word-chip-btn:hover {
  background: #ccfbf1;
  border-color: var(--island-teal);
  transform: translateY(-2px);
}

.builder-feedback {
  background: #f0fdfa;
  border: 1.5px solid #5eead4;
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.95rem;
  color: #115e59;
}

.builder-footer {
  display: flex;
  justify-content: flex-end;
}

/* ================== TAB 3: FIGURATIVE DETECTIVE ================== */
.detective-header {
  margin-bottom: 1.2rem;
}

.detective-hud {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #ffffff;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.detective-card {
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
}

.magnifier-icon {
  font-size: 2.5rem;
}

.detective-quote {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--island-dark);
  border-left: 4px solid var(--island-teal);
  padding-left: 1.2rem;
  font-style: italic;
  line-height: 1.35;
}

.device-buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.device-btn {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.device-btn:hover {
  background: #f0fdfa;
  border-color: var(--island-teal);
  transform: translateY(-2px);
}

.device-btn.correct {
  background: #dcfce7 !important;
  border-color: #16a34a !important;
  color: #14532d !important;
}

.device-btn.wrong {
  background: #fee2e2 !important;
  border-color: #dc2626 !important;
  color: #7f1d1d !important;
}

.dev-name {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
}

.device-btn small {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.2rem;
}

.detective-exp {
  background: #f0fdfa;
  border: 1.5px solid #5eead4;
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.95rem;
  color: #115e59;
}

.detective-footer {
  display: flex;
  justify-content: flex-end;
}

/* ================== TAB 4: SPEED FIXER ================== */
.fixer-stage {
  max-width: 780px;
  margin: 0 auto;
}

.fixer-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.fixer-arena {
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.boring-box {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.boring-tag {
  font-size: 0.78rem;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
}

.boring-box h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: #334155;
  margin-top: 0.3rem;
}

.fixer-prompt {
  font-size: 1rem;
  font-weight: 700;
  color: var(--island-dark);
}

.fixer-choices {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.fixer-choice-btn {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.fixer-choice-btn:hover {
  background: #f0fdfa;
  border-color: var(--island-teal);
  transform: translateX(4px);
}

.btn-action {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 800;
  background: var(--island-teal);
  color: #fff;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover {
  background: #0f766e;
  transform: translateY(-2px);
}

@media (max-width: 800px) {
  .similes-layout, .device-buttons-grid {
    grid-template-columns: 1fr;
  }
}
