:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --secondary: #0284c7;
  --accent: #f59e0b;
  --bg-dark: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-heading: 'Bricolage Grotesque', sans-serif;
  --font-body: 'Lexend', sans-serif;
}

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

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

header {
  background-color: #1e293b;
  border-bottom: 2px solid var(--card-border);
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  font-size: 2rem;
  background: rgba(16, 185, 129, 0.2);
  border: 2px solid var(--primary);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.brand h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
}

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

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

.tab-pills {
  display: flex;
  background: #0f172a;
  padding: 4px;
  border-radius: 999px;
  gap: 4px;
  border: 1px solid var(--card-border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: #064e3b;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.tab-btn:hover:not(.active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.btn-header {
  background: #334155;
  color: #fff;
  border: none;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: 0.2s;
}

.btn-header:hover {
  background: #475569;
}

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

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

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

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

.mode-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  background: var(--card-bg);
  padding: 1rem 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--card-border);
}

.section-intro h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: #fff;
}

.section-intro p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 2px;
}

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

.action-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}

.action-btn.primary {
  background: var(--primary);
  color: #064e3b;
  font-weight: 700;
}

.action-btn.primary:hover:not(:disabled) {
  background: #34d399;
}

.action-btn.secondary {
  background: #334155;
  color: white;
}

.action-btn.secondary:hover:not(:disabled) {
  background: #475569;
}

.action-btn.checkout-btn {
  background: #10b981;
  color: #064e3b;
  font-weight: 800;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 10px;
  justify-content: center;
}

.action-btn.large-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1.1rem;
}

/* ================= TAB 1: SHELVES & CHECKOUT ================= */
.shop-grid-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
}

.shelves-container {
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.25rem;
}

.shelf-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.5rem;
}

.shelf-header h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: #fff;
}

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

.shelves {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.85rem;
}

.shop-item-card {
  background: #0f172a;
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.shop-item-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.shop-item-card:active {
  transform: scale(0.95);
}

.item-icon {
  font-size: 2.5rem;
  margin-bottom: 0.35rem;
  display: block;
}

.item-ga {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  display: block;
}

.item-en {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
}

.item-price {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--primary);
  color: #34d399;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  display: inline-block;
}

/* Till & Basket */
.checkout-panel {
  display: flex;
  flex-direction: column;
}

.till-card {
  background: #1e293b;
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.till-screen {
  background: #064e3b;
  border: 3px solid #047857;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.till-label {
  font-size: 0.75rem;
  color: #a7f3d0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.till-amount {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 800;
  color: #6ee7b7;
  line-height: 1.1;
  margin: 0.25rem 0;
}

.till-item-count {
  font-size: 0.8rem;
  color: #d1fae5;
}

.basket-list-wrap {
  flex: 1;
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 240px;
}

.basket-list-wrap h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: #cbd5e1;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.35rem;
}

.basket-items {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.empty-basket-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin: auto 0;
  padding: 1rem;
}

.basket-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e293b;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.basket-row-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.basket-row-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.basket-qty-btn {
  background: #334155;
  color: white;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

/* ================= TAB 2: DIALOGUE ================= */
.dialogue-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
}

.dialogue-flow {
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.speech-bubble {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.speech-bubble.customer {
  flex-direction: row;
}

.speech-bubble.shopkeeper {
  flex-direction: row-reverse;
}

.bubble-avatar {
  font-size: 2rem;
  background: #0f172a;
  border: 2px solid var(--card-border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bubble-content {
  background: #0f172a;
  border: 1px solid var(--card-border);
  padding: 0.75rem 1rem;
  border-radius: 14px;
  max-width: 80%;
  position: relative;
}

.speech-bubble.customer .bubble-content {
  border-top-left-radius: 2px;
  border-color: #38bdf8;
}

.speech-bubble.shopkeeper .bubble-content {
  border-top-right-radius: 2px;
  border-color: #34d399;
}

.speaker-role {
  font-size: 0.75rem;
  font-weight: 700;
  display: block;
  margin-bottom: 0.2rem;
}

.speech-bubble.customer .speaker-role { color: #38bdf8; }
.speech-bubble.shopkeeper .speaker-role { color: #34d399; }

.bubble-text-ga {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  display: block;
}

.bubble-text-en {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.2rem;
}

.bubble-audio-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.bubble-audio-btn:hover { opacity: 1; }

.dialogue-practice-box {
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.25rem;
}

.dialogue-practice-box h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 0.75rem;
}

.phrase-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.phrase-pill {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.phrase-pill strong { color: #34d399; }
.phrase-pill span { color: var(--text-muted); font-size: 0.75rem; }

.btn-say {
  background: #334155;
  border: none;
  border-radius: 6px;
  padding: 0.25rem 0.45rem;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ================= TAB 3: MAKE THE CHANGE ================= */
.change-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
}

.change-problem-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.receipt-box {
  background: #fff;
  color: #0f172a;
  border-radius: 10px;
  padding: 1.25rem;
  font-family: 'Courier New', Courier, monospace;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.receipt-header {
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 1px;
  border-bottom: 2px dashed #64748b;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.receipt-divider {
  border-bottom: 1px solid #cbd5e1;
  margin: 0.5rem 0;
}

.target-row {
  font-weight: 800;
  font-size: 1.1rem;
  color: #047857;
}

.till-tray {
  background: #1e293b;
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 1rem;
}

.till-tray h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: #cbd5e1;
  margin-bottom: 0.5rem;
}

.tray-coins {
  background: #0f172a;
  border: 2px dashed var(--card-border);
  border-radius: 10px;
  min-height: 90px;
  padding: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.empty-tray-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
}

.tray-sum-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 1rem;
  color: #cbd5e1;
}

.tray-sum-bar strong {
  color: #38bdf8;
  font-size: 1.2rem;
}

.tray-actions {
  display: flex;
  gap: 0.4rem;
}

.change-feedback {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.change-feedback.correct {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid #10b981;
  color: #34d399;
}

.change-feedback.wrong {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #f87171;
}

.change-feedback.hidden {
  display: none;
}

.euro-bank-panel {
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.25rem;
}

.euro-bank-panel h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: #fff;
  margin-bottom: 0.35rem;
}

.drawer-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.coins-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.money-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.money-btn:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
}

.money-btn.note {
  background: #1e3a8a;
  border-color: #3b82f6;
  grid-column: span 1;
}

.coin-chip {
  background: #334155;
  border: 1px solid #64748b;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ================= TAB 4: RACE ================= */
.race-container {
  max-width: 900px;
  margin: 0 auto;
}

.race-card {
  background: #1e293b;
  border: 2px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
}

.race-header {
  display: flex;
  justify-content: space-around;
  background: #0f172a;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  margin-bottom: 1.25rem;
}

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

.race-stat strong {
  color: #fff;
  font-size: 1.2rem;
}

#race-start-overlay {
  text-align: center;
  padding: 2.5rem 1rem;
}

#race-start-overlay h3 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  color: #34d399;
  margin-bottom: 0.5rem;
}

#race-start-overlay p {
  color: #cbd5e1;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.order-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: #facc15;
  margin-bottom: 0.5rem;
}

.target-list {
  background: #0f172a;
  border: 2px solid #eab308;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fef08a;
}

.race-shelves-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .shop-grid-layout,
  .dialogue-container,
  .change-layout {
    grid-template-columns: 1fr;
  }
}
