/* =============================================
   雞蛋仔大亨 — EggWaffle Tycoon Styles
   ============================================= */

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

:root {
  --hk-red: #C41E3A;
  --hk-gold: #D4A017;
  --hk-brown: #5C3A1E;
  --hk-cream: #FFF8E7;
  --hk-dark: #2A1A0A;
  --hk-green: #2D5A27;
  --hk-orange: #E8751A;
  --panel-bg: rgba(42, 26, 10, 0.95);
  --panel-border: rgba(212, 160, 23, 0.35);
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

html, body {
  height: 100%;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  background: #1a0e05;
  color: var(--hk-cream);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ===================== APP CONTAINER ===================== */
.app-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ===================== GAME AREA ===================== */
.game-area {
  position: absolute;
  inset: 0;
}

#game-stage {
  position: absolute;
  width: 1920px;
  height: 1080px;
  transform-origin: center center;
  overflow: hidden;
}

#background-img {
  width: 100%; height: 100%;
  object-fit: cover;
}

#customer-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1920px;
  height: 700px;
  pointer-events: none;
  overflow: hidden;
}

#stage-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.1) 0%,
    rgba(0,0,0,0) 30%,
    rgba(0,0,0,0) 70%,
    rgba(0,0,0,0.5) 100%
  );
  pointer-events: none;
}

#day-progress-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 20px;
  background: rgba(0,0,0,0.7);
  z-index: 90;
}

#day-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--hk-gold), var(--hk-orange));
  width: 0%;
  transition: width 0.1s linear;
}

/* ===================== CUSTOMER SPRITES ===================== */
.customer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 360px;
  height: 631px;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(2px 3px 4px rgba(0,0,0,0.35));
}

.customer.walking-right {
  animation: walkRight var(--walk-duration, 8s) linear forwards;
}

.customer.walking-left {
  animation: walkLeft var(--walk-duration, 8s) linear forwards;
}

.customer.walking-right-buy {
  animation: walkRightBuy var(--walk-duration, 8s) linear forwards;
}

.customer.walking-left-buy {
  animation: walkLeftBuy var(--walk-duration, 8s) linear forwards;
}

@keyframes walkRight {
  from { transform: translateX(-360px) scale(var(--depth, 1)); }
  to   { transform: translateX(2280px) scale(var(--depth, 1)); }
}

@keyframes walkLeft {
  from { transform: translateX(2280px) scaleX(-1) scale(var(--depth, 1)); }
  to   { transform: translateX(-360px) scaleX(-1) scale(var(--depth, 1)); }
}

@keyframes walkRightBuy {
  0%   { transform: translateX(-360px) scale(var(--depth, 1)); }
  40%  { transform: translateX(560px) scale(var(--depth, 1)); }
  60%  { transform: translateX(560px) scale(var(--depth, 1)); }
  100% { transform: translateX(2280px) scale(var(--depth, 1)); }
}

@keyframes walkLeftBuy {
  0%   { transform: translateX(2280px) scaleX(-1) scale(var(--depth, 1)); }
  40%  { transform: translateX(560px) scaleX(-1) scale(var(--depth, 1)); }
  60%  { transform: translateX(560px) scaleX(-1) scale(var(--depth, 1)); }
  100% { transform: translateX(-360px) scaleX(-1) scale(var(--depth, 1)); }
}

.customer.fade-out {
  opacity: 0;
  transition: opacity 0.4s;
}

/* ===================== HUD ===================== */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 30px;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(42,26,10,0.92), rgba(42,26,10,0));
}

#hud-left {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

#hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

#hud-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.hud-stat {
  background: var(--hk-brown);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  padding: 4px 16px;
  font-size: 32px;
  color: var(--hk-cream);
  white-space: nowrap;
}

.hud-stat-price {
  color: #ffcc00;
  font-weight: bold;
}

#hud-soldstock {
  display: flex;
  gap: 8px;
}

.hud-tag {
  background: var(--hk-brown);
  border: 3px solid var(--panel-border);
  border-radius: 20px;
  padding: 10px 30px;
  font-size: 58px;
  font-weight: bold;
  white-space: nowrap;
}

.hud-money {
  background: var(--hk-green);
  border-color: #4a8a3f;
  color: #a8ff8a;
  font-size: 68px;
}

/* ===================== FLOATING COMMENTS ===================== */
#comment-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.floating-comment {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(42, 26, 10, 0.92);
  color: var(--hk-cream);
  border: 3px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 28px;
  font-size: 30px;
  font-weight: bold;
  white-space: nowrap;
  animation: floatUp 3s ease-out forwards;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
}

.floating-comment.comment-positive { border-color: #7fff7f; color: #a8ff8a; }
.floating-comment.comment-negative { border-color: #ff5555; color: #ffaaaa; }
.floating-comment.comment-neutral { border-color: #8ab4f8; color: #c5d6f0; }
.floating-comment.ambient { font-size: 20px; padding: 8px 16px; border-width: 2px; opacity: 0.9; }

@keyframes floatUp {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-160px); }
}

/* ===================== TOGGLE BUTTON ===================== */
.toggle-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--hk-gold);
  background: var(--panel-bg);
  color: var(--hk-gold);
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  animation: breatheBtn 3s ease-in-out infinite;
}

.toggle-btn:active {
  transform: scale(0.9);
  animation: none;
}

/* ===================== FULLSCREEN BUTTON ===================== */
.fullscreen-btn {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 200;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--hk-gold);
  background: var(--panel-bg);
  color: var(--hk-gold);
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  animation: breatheBtn 3s ease-in-out infinite;
}

.fullscreen-btn:active {
  transform: scale(0.9);
  animation: none;
}

.fullscreen-btn.active {
  background: var(--hk-green);
  border-color: #4a8a3f;
  color: #a8ff8a;
}

/* ===================== INTERRUPT FLOATING BUTTON ===================== */
.interrupt-float-btn {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 26px;
  border: 2px solid var(--hk-gold);
  background: var(--panel-bg);
  color: var(--hk-gold);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  animation: breatheBtn 3s ease-in-out infinite;
}

.interrupt-float-btn:active {
  transform: scale(0.9);
  animation: none;
}

/* ===================== LANGUAGE BUTTONS ===================== */
.lang-float-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: 26px;
  border: 2px solid var(--hk-gold);
  background: var(--panel-bg);
  color: var(--hk-gold);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  animation: breatheBtn 3s ease-in-out infinite;
}

.lang-float-btn:active {
  transform: scale(0.9);
  animation: none;
}

.lang-toggle {
  margin-top: 8px;
}

/* ===================== PANEL AREA ===================== */
.panel-area {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 60%;
  max-width: 60%;
  height: auto;
  max-height: 88%;
  overflow-y: auto;
  background: linear-gradient(135deg, #1a0e05, #2a1a0a);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px;
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}

.panel-area.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  animation: breathePanelGlow 3s ease-in-out infinite;
}

.panel-area--bottom {
  top: auto;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 0) scale(0.95);
  width: 80%;
  max-width: 80%;
  height: auto;
  max-height: 50%;
}

.panel-area--bottom.visible {
  transform: translate(-50%, 0) scale(1);
}

.panel-area::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.panel-area.visible::before {
  opacity: 1;
  pointer-events: auto;
}

.panel-area::-webkit-scrollbar {
  width: 6px;
}

.panel-area::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.3);
}

.panel-area::-webkit-scrollbar-thumb {
  background: var(--hk-gold);
  border-radius: 3px;
}

/* ===================== SCREENS ===================== */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

.panel {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.panel h2 {
  color: var(--hk-gold);
  font-size: 22px;
  text-align: center;
  margin-bottom: 14px;
}

.panel h3 {
  color: var(--hk-gold);
  font-size: 18px;
  margin-bottom: 10px;
}

/* ===================== TITLE SCREEN ===================== */
.title-panel {
  text-align: center;
  padding: 28px 20px;
}

.title-panel h1 {
  font-size: 34px;
  color: var(--hk-gold);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 2px;
}

.title-panel .subtitle {
  font-size: 18px;
  color: var(--hk-cream);
  opacity: 0.7;
  font-style: italic;
  margin-bottom: 10px;
}


/* ===================== TUTORIAL SLIDES ===================== */
.tutorial-slides {
  position: relative;
  margin: 12px 0;
  min-height: 180px;
}

.tutorial-slide {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 20px;
}

.tutorial-slide.active { display: flex; }

.tutorial-icon { font-size: 60px; margin-bottom: 14px; }

.tutorial-slide h3 {
  font-size: 26px;
  color: var(--hk-gold);
  margin-bottom: 12px;
}

.tutorial-slide p {
  font-size: 20px;
  line-height: 1.8;
  color: var(--hk-cream);
  max-width: 520px;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0;
}

.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  cursor: pointer;
  transition: background 0.2s;
}

.dot.active { background: var(--hk-gold); }

.tutorial-nav {
  display: flex;
  gap: 10px;
}

.tutorial-nav .btn { flex: 1; margin-top: 0; }

/* ===================== BUTTONS ===================== */
.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 12px;
  transition: transform 0.1s, filter 0.1s;
}

.btn:active {
  transform: scale(0.97);
  filter: brightness(0.9);
}

.btn-primary {
  background: linear-gradient(135deg, var(--hk-red), #a0162e);
  color: white;
  box-shadow: 0 3px 10px rgba(196,30,58,0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--hk-brown), #3a2010);
  color: var(--hk-cream);
  border: 1px solid var(--panel-border);
}

.btn-ghost {
  background: transparent;
  color: var(--hk-gold);
  border: 1px solid var(--hk-gold);
}

/* ===================== MORNING PANEL ===================== */
.summary-box {
  background: rgba(212,160,23,0.08);
  border: 1px solid rgba(212,160,23,0.25);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
  font-size: 18px;
  line-height: 1.7;
}

.section-box {
  margin-bottom: 16px;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 14px;
}

.section-box h3 {
  border-bottom: 1px solid rgba(212,160,23,0.15);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

/* Inventory + Buy (merged) */
.invbuy-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invbuy-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 18px;
  background: rgba(0,0,0,0.2);
  padding: 8px 10px;
  border-radius: 8px;
}

.invbuy-label {
  flex: 1;
  white-space: nowrap;
  min-width: 0;
}

.invbuy-stock {
  color: var(--hk-gold);
  font-size: 16px;
  white-space: nowrap;
}

.num-input {
  width: 60px;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.4);
  color: var(--hk-cream);
  text-align: center;
  font-size: 18px;
}

.num-input::placeholder {
  color: #555;
  font-size: 14px;
}

.num-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.num-input[type=number] {
  -moz-appearance: textfield;
}

.qty-group {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.qty-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--hk-brown);
  color: var(--hk-gold);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.1s;
  line-height: 1;
}

.qty-btn:active {
  filter: brightness(0.8);
  transform: scale(0.95);
}

.qty-group .num-input {
  width: 50px;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.cost-line {
  font-size: 16px;
  color: var(--hk-gold);
  margin-top: 8px;
  text-align: right;
}

/* Recipe */
.recipe-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.recipe-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
}

.recipe-row span:first-child {
  min-width: 85px;
}

.recipe-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  border-radius: 5px;
  background: rgba(212,160,23,0.25);
  outline: none;
}

.recipe-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--hk-gold);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.recipe-slider::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--hk-gold);
  cursor: pointer;
  border: none;
}

.recipe-row span:last-child {
  min-width: 55px;
  text-align: right;
  color: var(--hk-gold);
  font-weight: bold;
  font-size: 18px;
}

.quality-line {
  font-size: 18px;
  text-align: center;
  margin-top: 8px;
}

.quality-line span {
  font-weight: bold;
  font-size: 24px;
}

/* Price */
.price-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  margin-bottom: 14px;
}

.price-row span:first-child { flex: 1; }

.price-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  border-radius: 5px;
  background: rgba(212,160,23,0.25);
  outline: none;
}

.price-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--hk-gold);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.price-display {
  color: var(--hk-gold) !important;
  font-size: 24px !important;
  font-weight: bold;
  min-width: 60px;
  text-align: right;
}

.price-row span:last-child { min-width: 60px; text-align: right; }

.batch-info {
  text-align: center;
  font-size: 18px;
  color: var(--hk-gold);
  margin: 12px 0;
  padding: 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* ===================== AI REVIEW PANEL ===================== */
.ai-review-panel { text-align: center; }

.ai-review-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.ai-review-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.3);
  padding: 16px 20px;
  border-radius: 10px;
}

.ai-review-label {
  font-size: 18px;
  color: #aaa;
}

.ai-review-value {
  font-size: 20px;
  font-weight: bold;
  color: var(--hk-gold);
}

/* ===================== SIM PANEL ===================== */
.sim-panel { text-align: center; }

.sim-grid {
  display: flex;
  gap: 16px;
  margin: 20px 0;
}

.sim-grid > div {
  flex: 1;
  background: rgba(0,0,0,0.3);
  padding: 24px 12px;
  border-radius: 12px;
  font-size: 24px;
  font-weight: bold;
}

.sim-label {
  display: block;
  color: #aaa;
  font-size: 16px;
  font-weight: normal;
  margin-bottom: 4px;
}

#sim-title {
  font-size: 28px;
}

#sim-progress-bar {
  width: 100%;
  height: 14px;
  background: rgba(212,160,23,0.15);
  border-radius: 4px;
  margin: 16px 0;
  overflow: hidden;
}

#sim-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--hk-gold), var(--hk-orange));
  border-radius: 4px;
  width: 0%;
  transition: width 0.1s linear;
}

/* ===================== RESULTS ===================== */
.results-panel {
  display: flex;
  flex-direction: column;
}

.results-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.results-footer {
  flex-shrink: 0;
  padding-top: 10px;
}

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

.result-item {
  background: rgba(0,0,0,0.3);
  padding: 8px 6px;
  border-radius: 8px;
  text-align: center;
}

.result-label {
  display: block;
  font-size: 11px;
  color: #aaa;
  margin-bottom: 2px;
}

.result-value {
  display: block;
  font-size: 18px;
  font-weight: bold;
  color: var(--hk-gold);
}

.results-two-col {
  display: flex;
  flex-direction: row;
  gap: 16px;
  margin-top: 10px;
}

.feedback-col {
  flex: 1;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 10px;
}

.feedback-col h3 {
  font-size: 13px;
  margin: 0 0 6px 0;
}

.feedback-col ul {
  list-style: none;
}

.feedback-col li {
  font-size: 14px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.feedback-col li.comment-positive { color: #a8ff8a; }
.feedback-col li.comment-negative { color: #ffaaaa; }
.feedback-col li.comment-tip { color: #ffd76e; font-size: 13px; }

.cost-col {
  flex: 1;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 10px;
}

.cost-col h3 {
  font-size: 13px;
  margin: 0 0 6px 0;
}

.cost-breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.cost-breakdown-total {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: bold;
  padding-top: 4px;
  border-top: 1px solid var(--hk-gold);
  color: var(--hk-gold);
}

.cost-breakdown-label {
  color: #ccc;
}

.cost-breakdown-value {
  color: #fff;
}

.recipe-reminder {
  font-size: 16px;
  color: var(--hk-gold);
  text-align: center;
  padding: 8px 10px;
  margin-bottom: 12px;
  background: rgba(212,160,23,0.08);
  border-radius: 6px;
}

.waste-box {
  background: rgba(200,50,50,0.12);
  border: 1px solid rgba(200,50,50,0.25);
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
}

#profit-chart-container {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
}

#profit-chart-container h3 {
  font-size: 13px;
  margin: 0 0 6px 0;
}

#profit-chart {
  width: 100%;
  height: auto;
  display: block;
}

.salary-box {
  background: rgba(50,150,200,0.12);
  border: 1px solid rgba(50,150,200,0.25);
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
}

.vacation-box {
  background: rgba(50,150,200,0.12);
  border: 1px solid rgba(50,150,200,0.25);
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
}

/* ===================== AI PANEL ===================== */
.ai-panel { padding: 20px; }

.story-box {
  background: rgba(50,150,200,0.12);
  border: 1px solid rgba(50,150,200,0.3);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  text-align: center;
  font-size: 15px;
  line-height: 1.7;
}

.story-box strong {
  color: var(--hk-gold);
}

.ai-intro {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 12px;
  color: #bbb;
  text-align: center;
}

.prompt-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.prompt-section label {
  display: block;
  font-size: 15px;
  color: var(--hk-gold);
  margin-bottom: 3px;
  font-weight: bold;
}

.prompt-section textarea {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.4);
  color: var(--hk-cream);
  font-size: 15px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.prompt-section textarea::placeholder { color: #666; }

.context-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212,160,23,0.15);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  color: #999;
  line-height: 1.5;
  min-height: 60px;
  white-space: pre-wrap;
}

.ai-context-options {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.ctx-option {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #bbb;
  cursor: pointer;
  background: rgba(0,0,0,0.3);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(212,160,23,0.15);
}

.ctx-option input {
  accent-color: var(--hk-gold);
}

#ai-daily-config {
  margin: 8px 0;
  font-size: 13px;
  text-align: center;
}

#ai-daily-config label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

/* ===================== FINAL SCREEN ===================== */
.final-panel { text-align: center; padding: 28px 20px; }

.final-profit {
  font-size: 34px;
  font-weight: bold;
  color: var(--hk-gold);
  margin: 14px 0;
}

.name-entry {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.name-entry label {
  font-size: 18px;
  color: var(--hk-cream);
}

.name-input {
  width: 200px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--panel-border);
  background: rgba(0,0,0,0.4);
  color: var(--hk-cream);
  font-size: 22px;
  text-align: center;
}

.name-input::placeholder {
  color: #666;
  font-size: 18px;
}

.scores-box { margin: 14px 0; }

.scores-box ol {
  text-align: left;
  padding-left: 24px;
}

.scores-box li {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* ===================== HIGHSCORE LIST ===================== */
.highscore-list { list-style: none; }

.highscore-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.highscore-list li:first-child {
  background: rgba(212,160,23,0.15);
  border: 1px solid var(--hk-gold);
}

.hs-rank {
  font-weight: bold;
  color: var(--hk-gold);
  min-width: 28px;
}

.hs-name { flex: 1; }

.hs-score {
  font-weight: bold;
  color: #7fff7f;
}

/* Folded leaderboard: clickable rows + expandable sub-attempts */
.hs-row { cursor: pointer; }
.hs-row:hover { background: rgba(212,160,23,0.22); }
.hs-expandable { border-bottom: 1px solid rgba(212,160,23,0.15); }

.hs-chevron {
  color: var(--hk-gold);
  font-size: 12px;
  margin-left: 8px;
  margin-right: 16px;
  white-space: nowrap;
}

.hs-subs {
  list-style: none;
  padding: 2px 0 6px 22px;
}

.hs-sub {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 5px 10px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #ccc;
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  border: none;
}

.hs-sub-dot { color: var(--hk-gold); opacity: 0.6; }
.hs-sub-info { flex: 1; }

/* ===================== MODAL ===================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 300;
}

.modal-content {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  padding: 24px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}

.modal-content h3 { color: var(--hk-gold); margin-bottom: 10px; font-size: 18px; }

.modal-content p {
  font-size: 13px;
  color: #bbb;
  margin-bottom: 14px;
  line-height: 1.5;
}

.api-input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.4);
  color: var(--hk-cream);
  font-size: 14px;
  margin-bottom: 14px;
}

.modal-buttons { display: flex; gap: 10px; }
.modal-buttons .btn { flex: 1; margin-top: 0; }

/* ===================== BANKRUPT ===================== */
.bankrupt-panel {
  text-align: center;
  padding: 28px 20px;
  border-color: rgba(200,50,50,0.5);
}

.bankrupt-panel h2 {
  font-size: 28px;
  color: #ff5555;
}

/* ===================== DEBUG MODAL ===================== */
.debug-content {
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}

.debug-section {
  margin-bottom: 12px;
}

.debug-section label {
  display: block;
  font-size: 12px;
  color: var(--hk-gold);
  margin-bottom: 4px;
  font-weight: bold;
}

#debug-gate-pw {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  text-align: left;
  font-size: 16px;
}

.debug-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--hk-brown);
  color: var(--hk-cream);
  cursor: pointer;
  transition: filter 0.1s;
}

.btn-small:active {
  filter: brightness(0.85);
}

.debug-select {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.4);
  color: var(--hk-cream);
  font-size: 12px;
}

/* ===================== QUALITY COLORS ===================== */
.quality-great { color: #7fff7f !important; }
.quality-good  { color: #ffd700 !important; }
.quality-fair  { color: #ffaa00 !important; }
.quality-poor  { color: #ff5555 !important; }

/* ===================== HISTORY LOG ===================== */
#history-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 8px;
}

#history-log-table th {
  background: rgba(212,160,23,0.15);
  color: var(--hk-gold);
  padding: 5px 4px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: bold;
  text-align: center;
}

#history-log-table td {
  padding: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  text-align: center;
  color: #ccc;
}

#history-log-table tr:hover td {
  background: rgba(212,160,23,0.05);
}

#history-log-table .profit-pos { color: #7fff7f; }
#history-log-table .profit-neg { color: #ff5555; }

#history-log-body {
  max-height: 200px;
  overflow-y: auto;
}

#history-log-body::-webkit-scrollbar { width: 4px; }
#history-log-body::-webkit-scrollbar-thumb { background: var(--hk-gold); border-radius: 2px; }

/* ===================== STEP WIZARD ===================== */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 16px;
}

.step-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 2px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: #888;
  transition: all 0.3s;
}

.step-dot.active {
  background: var(--hk-gold);
  border-color: var(--hk-gold);
  color: var(--hk-dark);
  box-shadow: 0 0 10px rgba(212,160,23,0.4);
}

.step-line {
  width: 50px;
  height: 3px;
  background: var(--panel-border);
  margin: 0 4px;
}

.morning-step {
  min-height: 200px;
}

.step-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.step-nav .btn {
  flex: 1;
  margin-top: 0;
}

/* ===================== ROTATE OVERLAY ===================== */
#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #1a0e05;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.rotate-content {
  text-align: center;
  color: var(--hk-cream);
}

.rotate-icon {
  font-size: 60px;
  margin-bottom: 16px;
  animation: rotateHint 1.5s ease-in-out infinite;
}

.rotate-content p {
  font-size: 18px;
  margin: 6px 0;
}

.rotate-sub {
  font-size: 13px;
  color: #888;
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

@media (max-width: 767px) and (orientation: portrait) {
  #rotate-overlay {
    display: flex;
  }
  .app-container {
    display: none;
  }
}

#rotate-overlay.js-show {
  display: flex !important;
}

#rotate-overlay.js-show ~ .app-container {
  display: none !important;
}

/* ===================== MOBILE (<768px) ===================== */
@media (max-width: 767px) {
  .panel-area {
    width: 92vw;
    max-width: 92vw;
    height: 85vh;
    max-height: 85vh;
    padding: 6px;
  }

  .panel-area--bottom {
    width: 96vw;
    max-width: 96vw;
    max-height: 60%;
    bottom: 10px;
  }

  .panel { padding: 14px; }

  .hud-tag { font-size: 28px; padding: 6px 16px; border-radius: 14px; border-width: 2px; }
  .hud-money { font-size: 32px; }
  .hud-stat { font-size: 18px; padding: 2px 10px; border-radius: 10px; border-width: 1px; }
  #hud-stats { gap: 2px; }
  #hud-soldstock { gap: 4px; }
  #hud { padding: 10px 14px; }
  #hud-left { gap: 8px; }
  #hud-right { gap: 2px; }
  .fullscreen-btn { width: 40px; height: 40px; font-size: 18px; bottom: 10px; left: 10px; }

  .title-panel h1 { font-size: 26px; }
  .title-panel .subtitle { font-size: 14px; }
  .tutorial-slide { padding: 12px 10px; }
  .tutorial-icon { font-size: 38px; }
  .tutorial-slide h3 { font-size: 16px; }
  .tutorial-slide p { font-size: 14px; }
  .tutorial-dots { gap: 6px; }
  .dot { width: 8px; height: 8px; }

  .sim-grid { gap: 6px; flex-direction: column; }
  .sim-grid > div { padding: 12px; font-size: 16px; }

  .invbuy-row { font-size: 14px; padding: 5px 6px; }
  .invbuy-stock { font-size: 12px; }
  .num-input { width: 44px; font-size: 14px; }
  .recipe-row { font-size: 14px; }
  .recipe-row span:last-child { font-size: 14px; }
  .price-row { font-size: 14px; }
  .batch-info { font-size: 14px; }
  .cost-line { font-size: 13px; }
  .summary-box { font-size: 14px; }
  .recipe-reminder { font-size: 13px; }

  .results-grid { gap: 5px; }
  .result-value { font-size: 17px; }
  .results-two-col { flex-direction: column; }
}

/* ===================== SMALLER SCREENS (768px–1100px) ===================== */
@media (min-width: 768px) and (max-width: 1100px) {
  .panel-area {
    padding: 8px;
  }

  .panel-area--bottom {
    width: 88vw;
    max-width: 88vw;
    max-height: 55%;
  }

  .panel {
    padding: 18px;
  }

  .panel h2 {
    font-size: 20px;
    margin-bottom: 10px;
  }

  .sim-grid { gap: 10px; }
  .sim-grid > div { padding: 16px 10px; font-size: 18px; }
  .sim-label { font-size: 14px; }

  .results-grid {
    gap: 4px;
  }

  .result-value {
    font-size: 16px;
  }

  .title-panel h1 {
    font-size: 28px;
  }

  .tutorial-slide h3 { font-size: 17px; }
  .tutorial-slide p { font-size: 14px; }
}

/* ===================== WIDE SCREEN ===================== */
/* 16:9 lock handles all screen sizes — no wide screen override needed */

/* ===================== BREATHING ANIMATIONS ===================== */
@keyframes breathePanelGlow {
  0%, 100% { box-shadow: 0 8px 40px rgba(0,0,0,0.7); }
  50% { box-shadow: 0 8px 60px rgba(212,160,23,0.3), 0 0 80px rgba(212,160,23,0.1); }
}

@keyframes breatheBtn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
