:root {
  --bg: #1b120e;
  --bg-soft: #2a1a13;
  --panel: rgba(39, 24, 18, 0.92);
  --panel-border: rgba(255, 183, 107, 0.2);
  --ink: #fff6ea;
  --muted: #ccb49c;
  --fire: #ff6b2c;
  --fire-deep: #d93f16;
  --gold: #f5b731;
  --perfect: #ffe066;
  --green: #38b764;
  --danger: #ff4747;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

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

html,
body {
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #3a2116 0%, var(--bg) 65%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
  font-family: inherit;
}

.app-shell {
  max-width: 680px;
  height: 100dvh;
  margin: 0 auto;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.home-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.home-link:hover {
  background: rgba(255, 255, 255, 0.14);
}

.game-title {
  font-size: clamp(0.92rem, 2.8vw, 1.1rem);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stat-pill {
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  min-width: 50px;
}

.stat-label {
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-pill strong {
  font-size: 0.92rem;
  color: #fff;
}

.stat-combo strong {
  color: var(--gold);
}

.hearts-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px 7px;
  font-size: 0.9rem;
}

.heart.lost {
  opacity: 0.24;
  filter: grayscale(1);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* Dual Heat Gauges */
.gauges-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  flex-shrink: 0;
}

.gauge-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gauge-card.is-cooking .gauge-title {
  color: #fff;
}

.gauge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.76rem;
}

.gauge-title {
  font-weight: 700;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.side-badge {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.side-badge.is-active {
  background: linear-gradient(135deg, var(--fire), var(--fire-deep));
  color: #fff;
  box-shadow: 0 0 10px rgba(255, 107, 44, 0.45);
}

.gauge-meta {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.gauge-meta strong {
  color: #fff;
}

.gauge-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: #140d0a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

/* Golden zone 65-92% and Perfect 76-88% markers */
.zone-golden {
  position: absolute;
  left: 65%;
  width: 27%;
  top: 0;
  bottom: 0;
  background: rgba(245, 183, 49, 0.28);
  border-left: 1px dashed rgba(245, 183, 49, 0.8);
  border-right: 1px dashed rgba(245, 183, 49, 0.8);
  z-index: 1;
}

.zone-perfect {
  position: absolute;
  left: 76%;
  width: 12%;
  top: 0;
  bottom: 0;
  background: rgba(255, 232, 102, 0.42);
  border-left: 1px solid rgba(255, 240, 140, 0.95);
  border-right: 1px solid rgba(255, 240, 140, 0.95);
  z-index: 2;
}

.gauge-fill {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #f5ead9;
  transition: width 0.05s linear;
  z-index: 3;
  opacity: 0.9;
}

.gauge-fill.is-golden {
  background: linear-gradient(90deg, #f3a833, #ffd24c);
  box-shadow: 0 0 8px rgba(245, 183, 49, 0.65);
}

.gauge-fill.is-perfect {
  background: linear-gradient(90deg, #ffe066, #fff2a6);
  box-shadow: 0 0 12px rgba(255, 224, 102, 0.9);
}

.gauge-fill.is-warning {
  background: linear-gradient(90deg, #ff7b29, #ff4747);
}

.gauge-fill.is-burnt {
  background: linear-gradient(90deg, #5e1717, #220909);
}

.gauge-legend {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  font-size: 0.66rem;
  color: var(--muted);
}

.gauge-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-raw { background: #f5ead9; }
.dot-gold { background: #f5b731; }
.dot-perf { background: #ffe066; box-shadow: 0 0 6px #ffe066; }
.dot-burn { background: #ff4747; }

/* Wind Warning Banner */
.wind-banner {
  background: linear-gradient(90deg, #b82914, #ff6b2c, #b82914);
  color: #fff;
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 228, 160, 0.6);
  box-shadow: 0 6px 18px rgba(255, 85, 25, 0.45);
  animation: pulseBanner 0.55s ease-in-out infinite alternate;
  flex-shrink: 0;
}

@keyframes pulseBanner {
  from { transform: scale(1); }
  to { transform: scale(1.015); }
}

/* Canvas Stage */
.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  background: radial-gradient(circle at 50% 45%, #40261b 0%, #1c110c 85%);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

#grillCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

.toast-pill {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 12, 9, 0.86);
  border: 1px solid rgba(255, 210, 125, 0.45);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 9, 6, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 10;
}

.overlay[hidden],
.wind-banner[hidden],
.toast-pill[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: #271812;
  border: 1px solid rgba(255, 190, 115, 0.28);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.modal-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 107, 44, 0.2);
  color: #ff9c66;
  margin-bottom: 8px;
}

.modal-badge-dark {
  background: rgba(255, 71, 71, 0.2);
  color: #ff8a8a;
}

.modal-card h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 12px;
}

.tips-list {
  list-style: none;
  text-align: left;
  background: rgba(0, 0, 0, 0.26);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: #f4e4d2;
  margin-bottom: 12px;
}

.tips-list code {
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.76rem;
}

.record-row {
  display: flex;
  justify-content: space-around;
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.record-row strong {
  color: var(--gold);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.summary-item {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-item span {
  font-size: 0.72rem;
  color: var(--muted);
}

.summary-item strong {
  font-size: 1.15rem;
  color: var(--gold);
}

.best-combo-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.best-combo-note strong {
  color: #fff;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-btn,
.secondary-btn {
  min-height: 46px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  border: none;
  padding: 10px 12px;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, #ff7029, #d93f16);
  color: #fff;
  box-shadow: 0 8px 20px rgba(217, 63, 22, 0.4);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.primary-btn:active,
.secondary-btn:active {
  transform: scale(0.97);
}

.share-feedback {
  margin-top: 8px;
  min-height: 18px;
  font-size: 0.78rem;
  color: #8ce99a;
  font-weight: 600;
}

/* Bottom Controls */
.controls-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.action-btn {
  border: none;
  border-radius: 16px;
  padding: 10px 8px;
  min-height: 58px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.btn-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  text-align: left;
}

.btn-text strong {
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.btn-text small {
  font-size: 0.66rem;
  opacity: 0.88;
}

.btn-flip {
  background: linear-gradient(135deg, #e86b24, #c94412);
}

.btn-topping {
  background: linear-gradient(135deg, #d89b1c, #b5740a);
}

.btn-topping.is-topped {
  background: linear-gradient(135deg, #2b8a3e, #1e6b2e);
  opacity: 1;
}

.btn-serve {
  background: linear-gradient(135deg, #239653, #176d3b);
}

@media (max-width: 480px) {
  .app-shell {
    padding: 8px 8px 10px;
    gap: 6px;
  }

  .top-bar {
    padding: 6px 8px;
  }

  .game-title {
    display: none;
  }

  .gauges-panel {
    padding: 7px 10px;
    gap: 5px 8px;
  }

  .action-btn {
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    min-height: 60px;
  }

  .btn-text {
    align-items: center;
    text-align: center;
  }

  .btn-text strong {
    font-size: 0.74rem;
  }

  .btn-text small {
    font-size: 0.61rem;
  }
}
