/* ── Desktop ── */
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  background: transparent;
  font-family: 'Pixel Sans Serif', 'MS Sans Serif', Arial, sans-serif;
  font-size: 13px;
  overflow: hidden;
  height: 100vh;
}
#bgCanvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

/* ── Main window ── */
#mainWin {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 920px;
  z-index: 10;
}
#mainWin .window-body {
  padding: 6px;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

/* ── Menu bar ── */
.menubar {
  display: flex;
  padding: 2px 4px;
  border-bottom: 1px solid #808080;
  background: #c0c0c0;
  gap: 2px;
}
.menubar button {
  padding: 2px 10px;
  font-size: 13px;
  cursor: pointer;
}

/* ── Columns ── */
.col-left  { width: 180px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.col-center { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.col-right  { width: 190px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }

/* ── Fieldset tweaks ── */
fieldset { margin: 0; padding: 4px 8px 6px; }
fieldset legend { font-size: 13px; font-weight: bold; padding: 0 4px; }
fieldset p { margin: 2px 0; }

/* ── Score display ── */
.score-big {
  font-size: 26px; font-weight: bold;
  color: #000080; font-family: monospace;
  display: block; text-align: right;
  letter-spacing: 1px;
}
.score-target { text-align: right; font-size: 13px; color: #444; margin-top: 2px; }

/* ── Progress bar ── */
.progress-wrap { margin-top: 4px; }
progress { width: 100%; height: 16px; }

/* ── Sentiment ── */
.sentiment-val {
  display: inline-block;
  padding: 2px 10px;
  font-weight: bold; font-size: 13px;
  border: 1px solid;
}
.s-neutral  { color:#000; border-color:#808080; background:#c0c0c0; }
.s-bear     { color:#8b0000; border-color:#8b0000; background:#ffe0e0; }
.s-volatile { color:#b8860b; border-color:#b8860b; background:#fff4cc; }
.s-bull     { color:#006400; border-color:#006400; background:#e0ffe0; }

/* ── Slot canvas frame ── */
#slot-frame {
  background: #000080;
  padding: 4px;
  border: inset 2px;
  display: inline-block;
}
#game-container canvas { display: block; }

/* ── Spin button area ── */
.spin-row {
  display: flex; gap: 8px; align-items: center; margin-top: 2px;
  width: 100%; justify-content: center;
}
#btnSpin { padding: 6px 36px; font-size: 15px; font-weight: bold; min-width: 120px; }
#resultFlash {
  font-size: 13px; font-weight: bold;
  min-height: 18px; text-align: center;
}
.flash-win  { color: #006400; }
.flash-lose { color: #8b0000; }

/* ── Event fieldset ── */
.event-label { font-weight: bold; margin-bottom: 4px; font-size: 13px; }
.event-desc  { margin-bottom: 6px; color: #444; font-size: 12px; }
.effect-row  {
  padding: 3px 7px; margin-bottom: 3px;
  font-size: 12px; font-family: monospace;
  border-left: 3px solid;
}
.effect-target { border-color: #000080; background: #e8e8ff; color: #000080; }
.effect-action { border-color: #804000; background: #fff4e0; color: #804000; }
.effect-neutral{ border-color: #808080; background: #f0f0f0; color: #444; }

/* ── Synergy list ── */
.synergy-row {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 4px 6px; margin-bottom: 3px;
  background: #fff8d0; border: 1px solid #c8a000;
  font-size: 12px; line-height: 1.4;
}
.synergy-row strong { display: block; color: #7a5c00; }
.synergy-row span   { color: #555; font-size: 11px; }

/* ── Advisor list ── */
.advisor-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; margin-bottom: 3px;
  background: #e8e0f0; border: 1px solid #9060c0;
  font-size: 12px;
}
/* ── Advisor locked during spin ── */
#advisorFieldset.advisors-locked .adv-remove-btn {
  pointer-events: none;
  opacity: 0.35;
  cursor: default;
}

/* ── Advisor tooltip ── */
.advisor-row { position: relative; }
.advisor-row[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0; bottom: calc(100% + 4px);
  background: #ffffe1;
  border: 1px solid #808080;
  padding: 4px 7px;
  font-size: 11px; line-height: 1.5;
  color: #000;
  white-space: normal;
  width: 170px;
  z-index: 200;
  pointer-events: none;
  box-shadow: 2px 2px 0 #808080;
}

.adv-remove-btn {
  flex-shrink: 0;
  width: 18px; height: 18px;
  padding: 0; line-height: 16px; text-align: center;
  font-size: 13px; font-weight: bold;
  color: #8b0000; cursor: pointer;
  border-top-color: #fff; border-left-color: #fff;
  border-bottom-color: #808080; border-right-color: #808080;
}
.adv-remove-btn:hover { color: #cc0000; }

/* ── Status bar ── */
.status-bar { margin-top: 4px; }
.status-bar-field { flex: 1; }

/* ── Overlay backdrop ── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  align-items: center; justify-content: center;
}
.overlay.show { display: flex; }

/* ── Tutorial (guided tour) ── */
#tutorialBackdrop {
  display: none; position: fixed; inset: 0;
  z-index: 100;
  pointer-events: auto;
}
#tutorialBackdrop.show { display: block; }

.tutorial-highlight {
  position: relative;
  z-index: 101 !important;
  box-shadow: 0 0 0 4px #000080, 0 0 0 9999px rgba(0,0,0,0.5);
  border-radius: 2px;
}

#tutorialTooltip {
  display: none; position: absolute;
  z-index: 102;
  width: 340px;
  max-width: calc(100vw - 16px);
  pointer-events: auto;
}
#tutorialTooltip.show { display: block; }
#tutorialTooltip .window-body { padding: 12px 14px; }
#tutorialContent { padding: 4px 0; }

/* ── Disclaimer (must be above tutorial) ── */
#gameDisclaimerOverlay { z-index: 102; }

/* ── Upgrade dialog ── */
#upgradeWin  { width: 480px; }
#gameOverWin { width: 400px; }

/* ── End-of-game stats ── */
.stats-panel {
  text-align: left; margin-top: 10px;
  border: inset 2px; background: #fff;
  padding: 8px 10px; max-height: 200px; overflow-y: auto;
}
.stats-section { margin-bottom: 8px; }
.stats-section-title { font-size: 11px; font-weight: bold; color: #000080; text-transform: uppercase; margin-bottom: 4px; }
.stats-row { font-size: 12px; line-height: 1.6; }
.stats-row span { color: #666; }

.upgrade-grid {
  display: flex; gap: 8px; justify-content: center;
  flex-wrap: wrap; padding: 8px 0;
}
.upg-card {
  width: 130px; border: 2px solid;
  padding: 8px; cursor: pointer; text-align: center;
  background: #c0c0c0;
  border-top-color: #fff; border-left-color: #fff;
  border-bottom-color: #808080; border-right-color: #808080;
}
.upg-card:hover {
  border-top-color: #808080; border-left-color: #808080;
  border-bottom-color: #fff; border-right-color: #fff;
  background: #d4d0c8;
}
.upg-card.upg-advisor {
  background: #e8e0f0;
  border-top-color: #f0e8ff; border-left-color: #f0e8ff;
}
.upg-card.upg-advisor:hover { background: #d8c8f0; }
.upg-type-badge {
  font-size: 10px; letter-spacing: 1px; font-weight: bold;
  padding: 1px 6px; display: inline-block; margin-bottom: 6px;
  background: #000080; color: #fff;
}
.upg-advisor .upg-type-badge { background: #4b0082; }
.upg-icon { font-size: 2.2rem; margin: 4px 0; display: block; }
.upg-name { font-weight: bold; font-size: 13px; margin-bottom: 4px; }
.upg-desc { font-size: 13px; color: #333; line-height: 1.5; font-weight: 500; }
/* ── Advisor swap dialog ── */
#swapAdvisorWin { width: 360px; }
.swap-adv-card {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px; margin-bottom: 4px; cursor: pointer;
  background: #e8e0f0; border: 2px solid;
  border-top-color: #f0e8ff; border-left-color: #f0e8ff;
  border-bottom-color: #808080; border-right-color: #808080;
}
.swap-adv-card:hover {
  background: #d8c8f0;
  border-top-color: #808080; border-left-color: #808080;
  border-bottom-color: #f0e8ff; border-right-color: #f0e8ff;
}
.swap-adv-icon { font-size: 22px; flex-shrink: 0; }
.swap-adv-info { flex: 1; }
.swap-adv-name { font-weight: bold; font-size: 13px; }
.swap-adv-desc { font-size: 11px; color: #555; line-height: 1.4; margin-top: 2px; }

/* ── Prism override for small panel ── */
pre[class*="language-"] {
  margin: 0; padding: 6px 8px;
  font-size: 11px !important;
  border: inset 1px; background: #ffffff !important;
  max-height: 90px; overflow-y: auto;
}

/* ── Event reveal animation ── */
@keyframes eventReveal {
  0%   { box-shadow: inset 0 0 0 2px #ffcc00; background: #ffffd0; }
  60%  { box-shadow: inset 0 0 0 2px #ffcc00; background: #ffffd0; }
  100% { box-shadow: none; background: transparent; }
}
.event-revealing { animation: eventReveal 1.1s ease-out forwards; }

/* ── Score counter flash ── */
@keyframes scoreFlash {
  0%   { color: #000080; }
  30%  { color: #006400; transform: scale(1.12); }
  100% { color: #000080; transform: scale(1); }
}
.score-tick { animation: scoreFlash 0.18s ease-out; }

/* ── Phase status indicator ── */
#statusMsg { transition: opacity 0.2s; }

/* ══ AUTH ════════════════════════════════════════════════ */
.auth-bar { font-size: 12px; line-height: 22px; display: flex; align-items: center; gap: 6px; padding-left: 6px; }
.menubar-btn { font-size: 11px; padding: 1px 6px; cursor: pointer; }
.locale-game { display: flex; gap: 2px; margin-right: 6px; }
.locale-g-btn { font-weight: bold; }
.locale-active { background: #000080; color: #fff; }

/* ── Achievement toast (Steam-like) ── */
#achievementToast {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.ach-toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: #1a1a2e;
  border: 2px solid;
  border-top-color: #444; border-left-color: #444;
  border-bottom-color: #111; border-right-color: #111;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  min-width: 260px; max-width: 320px;
  animation: achSlideIn 0.4s ease-out, achFadeOut 0.5s ease-in 3.5s forwards;
  pointer-events: auto;
}
.ach-toast-img { width: 48px; height: 48px; flex-shrink: 0; border-radius: 50%; }
.ach-toast-info { flex: 1; }
.ach-toast-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #ffd700; font-weight: bold;
}
.ach-toast-name { font-size: 13px; color: #fff; font-weight: bold; margin-top: 2px; }
.ach-toast-desc { font-size: 11px; color: #aaa; margin-top: 1px; }

/* Guest variant: prompts player to log in to claim */
.ach-toast.ach-toast-guest {
  border-color: #ffd700;
  border-top-color: #ffe680; border-left-color: #ffe680;
  border-bottom-color: #b8860b; border-right-color: #b8860b;
}
.ach-toast-claim {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  font-size: 10px; font-weight: bold;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #1a1a2e; background: #ffd700;
  text-decoration: none; border-radius: 3px;
  pointer-events: auto; cursor: pointer;
}
.ach-toast-claim:hover { background: #ffe680; }

@keyframes achSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes achFadeOut {
  to { opacity: 0; transform: translateY(10px); }
}

/* ══ MOBILE ═════════════════════════════════════════════ */
@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  #mainWin {
    position: relative;
    top: 0; left: 0;
    transform: none;
    width: 100%;
    min-width: 0;
  }

  #mainWin .window-body {
    flex-direction: column;
    align-items: stretch;
  }

  .col-left, .col-right {
    width: 100%;
    flex-shrink: 1;
  }
  .col-center { width: 100%; }

  /* Scale canvas to fit screen */
  #slot-frame {
    max-width: 100%;
    overflow: hidden;
  }
  #slot-frame canvas,
  #game-container canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  .spin-row { flex-wrap: wrap; }
  #btnSpin { min-width: 100px; padding: 8px 20px; }

  .score-big { font-size: 22px; }

  /* Menubar wrap */
  .menubar { flex-wrap: wrap; gap: 4px; }
  .auth-bar { font-size: 11px; }

  /* Overlays fit mobile */
  .overlay { align-items: flex-start; padding: 16px 8px; overflow-y: auto; }
  #upgradeWin,
  #gameOverWin,
  #swapAdvisorWin,
  #tutorialTooltip,
  .overlay > .window { width: calc(100vw - 16px) !important; max-width: 480px; }

  .upg-card { width: 100%; }
  .upgrade-grid { flex-direction: column; }

  /* Stats panel */
  .stats-panel { max-height: 150px; }

  /* Tutorial tooltip — center on mobile */
  #tutorialTooltip {
    position: fixed !important;
    left: 8px !important;
    right: 8px;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: auto !important;
  }
}

@media (max-width: 400px) {
  .menubar { font-size: 10px; }
  .menubar-btn { font-size: 10px; padding: 1px 4px; }
  fieldset { padding: 3px 6px 4px; }
  fieldset legend { font-size: 12px; }
  .score-big { font-size: 20px; }
  #btnSpin { font-size: 14px; padding: 6px 16px; }
}

