/* ============================================
   Quarter Close — Spreadsheet Disguise CSS
   ============================================ */

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overscroll-behavior: none;
}

body {
  font-family: 'Segoe UI', Calibri, Arial, sans-serif;
  font-size: 12px;
  color: #212121;
  background: #f0f0f0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* ============================================
   Title Bar
   ============================================ */
#title-bar, #boss-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #217346;
  color: white;
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

#title-left, #boss-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

#title-right, #boss-title-right {
  display: flex;
  gap: 0;
}

.title-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 30px;
  cursor: pointer;
  font-size: 12px;
}

.title-btn:hover {
  background: rgba(255,255,255,0.15);
}

.title-close:hover {
  background: #e81123 !important;
}

/* ============================================
   Menu Bar
   ============================================ */
#menu-bar, #boss-menu-bar {
  display: flex;
  align-items: center;
  background: #f3f3f3;
  border-bottom: 1px solid #d6d6d6;
  height: 28px;
  padding: 0 4px;
}

.menu-item {
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  color: #444;
  border-radius: 2px;
  position: relative;
}

.menu-item:hover {
  background: #e0e0e0;
}

/* ============================================
   File Menu Dropdown
   ============================================ */
.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid #d0d0d0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  min-width: 200px;
  z-index: 1000;
  padding: 4px 0;
  border-radius: 0 0 4px 4px;
}

.menu-dropdown.open {
  display: block;
}

.menu-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  cursor: pointer;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
}

.menu-dropdown-item:hover {
  background: #e8f0fe;
}

.menu-dropdown-item .shortcut {
  color: #999;
  font-size: 11px;
  margin-left: 24px;
}

.menu-dropdown-sep {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 8px;
}

.menu-dropdown-item.toggle::before {
  content: '\2713';
  display: inline-block;
  width: 16px;
  margin-right: 4px;
  font-size: 11px;
  color: #217346;
}

.menu-dropdown-item.toggle.off::before {
  content: '';
}

/* About Modal */
#about-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#about-content {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 24px 32px;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

#about-content h3 {
  font-size: 18px;
  color: #217346;
  margin-bottom: 8px;
}

#about-content p {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

#about-content button {
  margin-top: 12px;
  background: #217346;
  color: white;
  border: none;
  padding: 6px 20px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

#about-content button:hover {
  background: #1a5c38;
}

/* Help Modal */
#help-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#help-content {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  max-width: 520px;
  max-height: 80vh;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e0e0e0;
}

.help-header h3 {
  font-size: 16px;
  color: #217346;
  margin: 0;
}

.help-close {
  background: none;
  border: none;
  font-size: 16px;
  color: #999;
  cursor: pointer;
  padding: 2px 6px;
}

.help-close:hover {
  color: #333;
}

.help-body {
  padding: 16px 20px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  color: #444;
}

.help-section {
  margin-bottom: 14px;
}

.help-section h4 {
  font-size: 13px;
  color: #217346;
  margin: 0 0 4px;
}

.help-section p {
  margin: 3px 0;
  color: #555;
}

.help-section b {
  color: #333;
}

/* Confirm Dialog */
#confirm-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#confirm-content {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 24px 32px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

#confirm-content p {
  font-size: 13px;
  color: #333;
  margin-bottom: 16px;
}

#confirm-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

#confirm-buttons button {
  padding: 6px 20px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid #ccc;
  background: white;
  color: #333;
}

#confirm-buttons button.confirm-danger {
  background: #d9534f;
  color: white;
  border-color: #d43f3a;
}

#confirm-buttons button.confirm-danger:hover {
  background: #c9302c;
}

#confirm-buttons button:not(.confirm-danger):hover {
  background: #f0f0f0;
}

/* ============================================
   Toolbar
   ============================================ */
#toolbar {
  display: flex;
  align-items: center;
  background: #f8f8f8;
  border-bottom: 1px solid #d6d6d6;
  height: 36px;
  padding: 0 8px;
  gap: 2px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  border-radius: 2px;
}

.tool-btn:hover {
  border-color: #c0c0c0;
  background: #e8e8e8;
}

.tool-select {
  height: 24px;
  border: 1px solid #c0c0c0;
  background: white;
  font-size: 11px;
  color: #333;
  padding: 0 4px;
  border-radius: 2px;
}

.font-select { width: 120px; }
.size-select { width: 50px; }

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: #d0d0d0;
  margin: 0 4px;
}

/* ============================================
   Formula Bar
   ============================================ */
#formula-bar, #boss-formula-bar {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #d6d6d6;
  height: 26px;
  font-size: 12px;
}

#cell-ref, .boss-cell-ref {
  width: 60px;
  text-align: center;
  border-right: 1px solid #d6d6d6;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f8f8;
  color: #333;
  font-size: 11px;
}

#fx-label, .boss-fx {
  padding: 0 8px;
  color: #888;
  border-right: 1px solid #d6d6d6;
  height: 100%;
  display: flex;
  align-items: center;
  font-style: italic;
}

#formula-input, .boss-formula-input {
  flex: 1;
  padding: 0 8px;
  color: #333;
  display: flex;
  align-items: center;
}

/* ============================================
   Column Headers
   ============================================ */
#col-headers {
  display: contents;
}

#col-headers > * {
  background: #f0f0f0;
  border-bottom: 1px solid #c0c0c0;
  height: 22px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.row-num-header {
  background: #f0f0f0;
  border-right: 1px solid #c0c0c0;
  height: 100%;
}

.col-header {
  text-align: center;
  font-size: 11px;
  color: #666;
  border-right: 1px solid #d6d6d6;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
}

/* ============================================
   Grid Container
   ============================================ */
#grid-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: white;
  display: grid;
  grid-template-columns: 40px max-content max-content max-content max-content max-content max-content max-content 1fr;
  align-content: start;
}

/* Grid Rows */
.grid-row {
  display: contents;
}

.grid-row > * {
  border-bottom: 1px solid #e8e8e8;
  min-height: 28px;
}

.grid-row:hover > * {
  background: #f5f9fc;
}

/* Wrapper divs inside grid must be transparent to grid layout */
#revenue-rows,
#tax-panel,
#filler-rows {
  display: contents;
}

.header-row > * {
  background: #f8f8f8;
  font-weight: 600;
}

.header-row:hover > * {
  background: #f0f4f7;
}

.row-num {
  text-align: center;
  color: #888;
  font-size: 11px;
  border-right: 1px solid #e0e0e0;
  background: #fafafa;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell {
  padding: 2px 6px;
  font-size: 12px;
  border-right: 1px solid #e8e8e8;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-a { color: #212121; }
.cell-b { justify-content: center; color: #444; }
.cell-c { justify-content: flex-end; color: #217346; font-family: 'Consolas', 'Courier New', monospace; font-size: 11px; }
.cell-d { justify-content: flex-end; color: #217346; font-family: 'Consolas', 'Courier New', monospace; font-size: 11px; }
.cell-e, .cell-f { justify-content: center; }
.cell-g { justify-content: flex-end; color: #217346; font-family: 'Consolas', 'Courier New', monospace; font-size: 11px; }
.cell-h { border-right: none; }

.empty-cell { border-right: 1px solid #e8e8e8; }

.header-cell {
  font-weight: 600;
  color: #333 !important;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Cash display */
.cash-label {
  font-weight: 700;
  color: #333;
}

.cash-value {
  font-weight: 700;
  color: #0b6623 !important;
  font-size: 13px !important;
  font-family: 'Consolas', 'Courier New', monospace;
}

.rev-label {
  justify-content: flex-end;
  color: #666;
  font-size: 11px;
}

.rev-value {
  color: #217346 !important;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
}

.per-tick-value {
  font-weight: 700;
  color: #0078d4 !important;
  font-size: 12px !important;
  font-family: 'Consolas', 'Courier New', monospace;
  animation: tick-pulse 1s ease-in-out infinite alternate;
}

@keyframes tick-pulse {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

.stats-header {
  font-weight: 600;
  color: #555;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-label {
  color: #888;
  font-size: 10px;
  justify-content: flex-end;
  padding-right: 4px !important;
}

.stats-val {
  color: #333;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
}

.sep-cell {
  background: #f5f5f5;
  height: 4px !important;
  min-height: 4px;
}

#row-sep {
  min-height: 4px;
  height: 4px;
}

#row-sep .row-num {
  font-size: 0;
  background: #f5f5f5;
}

/* Revenue source rows */
.source-name {
  font-weight: 500;
}

.source-locked {
  color: #999;
  font-style: italic;
}

.source-locked .cell {
  color: #bbb;
}

/* Buttons in cells */
.cell-btn {
  padding: 2px 8px;
  border: 1px solid #c0c0c0;
  background: #f0f0f0;
  cursor: pointer;
  font-size: 10px;
  border-radius: 2px;
  color: #333;
  font-family: 'Segoe UI', Arial, sans-serif;
  transition: all 0.1s;
  white-space: nowrap;
}

.cell-btn:hover {
  background: #e0e0e0;
  border-color: #999;
}

.cell-btn:active {
  background: #d0d0d0;
}

.cell-btn.btn-collect {
  background: #e8f5e9;
  border-color: #81c784;
  color: #2e7d32;
}

.cell-btn.btn-collect:hover {
  background: #c8e6c9;
}

.cell-btn.btn-hire {
  background: #e3f2fd;
  border-color: #90caf9;
  color: #1565c0;
}

.cell-btn.btn-hire:hover {
  background: #bbdefb;
}

.cell-btn.btn-max {
  background: none;
  border: none;
  color: #4a7ebb;
  font-size: 9px;
  padding: 0 3px;
  margin-right: 2px;
  text-decoration: underline;
  cursor: pointer;
}

.cell-btn.btn-max:hover {
  color: #1565c0;
}

.cell-btn.settle-flash {
  background: #fdd !important;
  color: #c00 !important;
  border-color: #c00 !important;
  font-size: 8px !important;
  animation: settle-shake 0.3s ease;
}

@keyframes settle-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.cell-btn.btn-upgrade {
  background: #fff3e0;
  border-color: #ffb74d;
  color: #e65100;
}

.cell-btn.btn-upgrade:hover {
  background: #ffe0b2;
}

.cell-btn.btn-unlock {
  background: #f3e5f5;
  border-color: #ce93d8;
  color: #7b1fa2;
}

.cell-btn.btn-unlock:hover {
  background: #e1bee7;
}

.cell-btn.btn-automate {
  background: #e0f2f1;
  border-color: #80cbc4;
  color: #00695c;
}

.cell-btn.btn-automate:hover {
  background: #b2dfdb;
}

.cell-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cell-btn:disabled:hover {
  background: #f0f0f0;
  border-color: #c0c0c0;
}

/* Auto indicator */
.auto-badge {
  font-size: 9px;
  color: #00897b;
  font-weight: 600;
  margin-left: 4px;
}

/* Filler rows */
.filler-row {
  display: contents;
}

.filler-row > * {
  border-bottom: 1px solid #f0f0f0;
  min-height: 24px;
}

.filler-row .row-num {
  color: #ccc;
  font-size: 10px;
}

.filler-row .cell {
  border-right: 1px solid #f0f0f0;
}

/* ============================================
   Sheet Tabs
   ============================================ */
/* Tax rows (rendered as grid rows) */
.tax-grid-header {
  background: #fff5f5 !important;
}

.tax-debt-row {
  background: #fffafa !important;
}

.tax-debt-row:hover {
  background: #fff0f0 !important;
}

.tax-total-row {
  background: #fff5f5 !important;
  border-top: 2px solid #dcc !important;
}

/* Revenue Breakdown Bar */
#revenue-breakdown {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  background: #f0f0f0;
  border-top: 1px solid #d0d0d0;
  font-size: 11px;
  font-family: 'Consolas', 'Courier New', monospace;
}

.rb-label {
  color: #666;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  font-weight: 600;
}

.rb-val {
  color: #333;
}

.rb-sep {
  color: #ccc;
  font-size: 10px;
}

#sheet-tabs, #boss-sheet-tabs {
  display: flex;
  align-items: flex-end;
  background: #e8e8e8;
  height: 28px;
  padding: 0 8px;
  border-top: 1px solid #c0c0c0;
  gap: 1px;
}

.sheet-tab {
  padding: 4px 16px;
  background: #f0f0f0;
  border: 1px solid #c0c0c0;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-size: 11px;
  color: #555;
  margin-top: 4px;
}

.sheet-tab.active {
  background: white;
  color: #217346;
  font-weight: 600;
  border-bottom: 1px solid white;
  margin-bottom: -1px;
}

.sheet-tab.disabled {
  color: #bbb;
  cursor: not-allowed;
  font-style: italic;
}

.sheet-tab.add-tab {
  background: transparent;
  border: none;
  color: #888;
  font-size: 14px;
  padding: 2px 10px;
}

#tab-spacer { flex: 1; }

/* ============================================
   Status Bar
   ============================================ */
#status-bar, #boss-status-bar {
  display: flex;
  align-items: center;
  background: #217346;
  color: white;
  height: 24px;
  padding: 0 12px;
  font-size: 11px;
}

#status-left { flex: 1; }
#status-center {
  flex: 1;
  text-align: center;
}
#status-right {
  flex: 1;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.status-sep { opacity: 0.5; }

.status-indicator {
  opacity: 0.9;
  font-size: 10px;
}

#boss-status-bar {
  display: flex;
  justify-content: space-between;
}

/* ============================================
   Game View Layout
   ============================================ */
#game-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* ============================================
   Boss View — Empty Spreadsheet
   ============================================ */
#boss-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

#boss-grid {
  flex: 1;
  background: white;
  display: grid;
  grid-template-columns: 40px repeat(10, 1fr);
  grid-template-rows: 22px repeat(30, 24px);
  overflow: hidden;
}

#boss-grid::before {
  content: '';
  grid-column: 1;
  grid-row: 1;
  background: #f0f0f0;
  border-right: 1px solid #c0c0c0;
  border-bottom: 1px solid #c0c0c0;
}

/* Boss grid generated via JS */
.boss-col-header {
  background: #f0f0f0;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #c0c0c0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #666;
}

.boss-row-num {
  background: #fafafa;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #999;
}

.boss-cell {
  border-right: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
}

/* ============================================
   Event Toast (Desktop notification style)
   ============================================ */
#event-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 380px;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 1000;
  font-size: 12px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

#toast-header {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  gap: 6px;
}

#toast-icon { font-size: 14px; }
#toast-title {
  font-weight: 600;
  color: #0078d4;
  flex: 1;
}

#toast-close {
  cursor: pointer;
  color: #888;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 2px;
}

#toast-close:hover {
  background: #e0e0e0;
}

#toast-sender {
  padding: 8px 10px 2px;
  font-weight: 600;
  color: #333;
}

#toast-body {
  padding: 4px 10px 8px;
  color: #555;
  line-height: 1.4;
}

#toast-actions {
  padding: 6px 10px 10px;
  display: flex;
  gap: 6px;
}

.toast-btn {
  padding: 4px 12px;
  border: 1px solid #c0c0c0;
  background: #f8f8f8;
  cursor: pointer;
  font-size: 11px;
  border-radius: 2px;
  color: #333;
}

.toast-btn:hover {
  background: #e8e8e8;
}

.toast-btn.toast-primary {
  background: #0078d4;
  color: white;
  border-color: #0078d4;
}

.toast-btn.toast-primary:hover {
  background: #106ebe;
}

.toast-btn-disabled, .toast-btn-disabled.toast-primary {
  background: #e0e0e0;
  color: #999;
  border-color: #ccc;
  cursor: not-allowed;
}

.toast-btn-disabled:hover, .toast-btn-disabled.toast-primary:hover {
  background: #e0e0e0;
  color: #999;
}

/* Timed event countdown */
.toast-countdown-wrapper {
  position: relative;
  height: 28px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  flex: 1;
}

.toast-countdown-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #d32f2f, #ff6659);
  animation: countdown-fill linear forwards;
  width: 0%;
}

@keyframes countdown-fill {
  from { width: 0%; }
  to { width: 100%; }
}

.toast-countdown-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  z-index: 1;
}

/* ============================================
   Offline Modal
   ============================================ */
#offline-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#offline-content {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 24px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
}

#offline-header {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #217346;
}

#offline-body {
  font-size: 13px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 16px;
}

#offline-ok {
  padding: 8px 24px;
  background: #217346;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}

#offline-ok:hover {
  background: #1a5c38;
}

/* ============================================
   Series A Modal
   ============================================ */
#series-a-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#series-a-content {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 0;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

#series-a-header {
  background: #f5f5f5;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid #e0e0e0;
  color: #0078d4;
}

#series-a-body {
  padding: 20px;
  font-size: 13px;
  color: #444;
  line-height: 1.6;
}

#series-a-body hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 12px 0;
}

.series-a-teaser {
  text-align: center;
  font-size: 15px;
  margin-top: 8px !important;
}

.series-a-sub {
  text-align: center;
  color: #888 !important;
  font-size: 12px !important;
}

#series-a-ok {
  display: block;
  margin: 0 20px 20px;
  padding: 10px 24px;
  background: #217346;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  width: calc(100% - 40px);
}

#series-a-ok:hover {
  background: #1a5c38;
}

/* ============================================
   Collect Flash Animation
   ============================================ */
.collect-flash {
  animation: flash 0.3s ease-out;
}

@keyframes flash {
  0% { background-color: #c8e6c9; }
  100% { background-color: transparent; }
}

/* Cash bump animation */
.cash-bump {
  animation: bump 0.2s ease-out;
}

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

/* ============================================
   Scrollbar Styling (subtle)
   ============================================ */
#grid-container::-webkit-scrollbar {
  width: 12px;
}

#grid-container::-webkit-scrollbar-track {
  background: #f0f0f0;
}

#grid-container::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border: 2px solid #f0f0f0;
  border-radius: 6px;
}

#grid-container::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* ============================================
   Arc Selection Screen
   ============================================ */
#arc-select {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #f0f0f0;
}

#arc-container {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 40px;
  max-width: 700px;
  width: 90%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#arc-header {
  text-align: center;
  margin-bottom: 30px;
}

#arc-title {
  font-size: 24px;
  font-weight: 600;
  color: #217346;
  margin-bottom: 4px;
}

#arc-subtitle {
  font-size: 14px;
  color: #666;
}

#arc-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.arc-option {
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.arc-option:hover {
  border-color: #217346;
  background: #f8fdf9;
}

.arc-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.arc-name {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.arc-desc {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

.arc-first {
  font-size: 10px;
  color: #999;
  font-style: italic;
}

#arc-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: #aaa;
  font-style: italic;
}

/* ============================================
   Mini-Task Bar
   ============================================ */
#mini-task-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 36px;
  background: #fffde7;
  border-bottom: 1px solid #f0e68c;
  font-size: 12px;
  max-width: 600px;
}

#mini-task-text {
  color: #333;
}

#mini-task-reward {
  color: #217346;
  font-weight: 600;
  font-size: 12px;
}

.mini-task-btn {
  background: #217346;
  color: white;
  border: none;
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.mini-task-btn:hover {
  background: #1a5c38;
}

.mini-task-skip {
  background: none;
  border: 1px solid #ccc;
  color: #999;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.mini-task-skip:hover {
  background: #f0f0f0;
  color: #666;
}

/* ============================================
   Time Scale Banner
   ============================================ */
#timescale-banner {
  text-align: center;
  padding: 8px 16px;
  background: #1a237e;
  color: white;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#timescale-banner.timescale-flash {
  animation: timescale-pulse 0.6s ease-in-out 3;
}

@keyframes timescale-pulse {
  0% { background: #1a237e; }
  50% { background: #4a148c; }
  100% { background: #1a237e; }
}

/* Golden Cell */
.golden-cell {
  animation: golden-pulse 0.8s ease-in-out infinite;
  cursor: pointer !important;
  position: relative;
  z-index: 2;
}

@keyframes golden-pulse {
  0% { background: #fff9c4; box-shadow: inset 0 0 8px rgba(255, 193, 7, 0.4); }
  50% { background: #ffecb3; box-shadow: inset 0 0 12px rgba(255, 152, 0, 0.6); }
  100% { background: #fff9c4; box-shadow: inset 0 0 8px rgba(255, 193, 7, 0.4); }
}

/* Selected cell highlight */
.cell.selected-cell {
  outline: 2px solid #217346;
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

/* Toast button countdown overlay */
.toast-btn-countdown {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: rgba(200, 0, 0, 0.25);
  animation: toast-btn-fill linear forwards;
  pointer-events: none;
  border-radius: 3px;
}

@keyframes toast-btn-fill {
  from { width: 0; }
  to { width: 100%; }
}

/* Valuation chart (floating Excel chart object) */
#valuation-chart-container {
  position: fixed;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #b0b0b0;
  border-radius: 2px;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.08);
  z-index: 10;
  cursor: move;
  user-select: none;
  min-width: 200px;
  min-height: 140px;
}

#valuation-chart-container .chart-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #b0b0b0 50%, #b0b0b0 60%, transparent 60%, transparent 75%, #b0b0b0 75%, #b0b0b0 85%, transparent 85%);
}

#valuation-chart-container:hover {
  border-color: #4472C4;
}

#valuation-chart {
  display: block;
  width: 100%;
  height: calc(100% - 18px);
}

.chart-title {
  font-size: 11px;
  font-weight: 600;
  color: #333;
  text-align: center;
  margin-bottom: 4px;
  font-family: 'Calibri', 'Segoe UI', sans-serif;
}

/* ============================================
   Phase 2.1: Investor Relations Section
   ============================================ */
.ir-header {
  background: #f0f7ff !important;
}

.ir-row {
  background: #fafcff !important;
}

.ir-row:hover {
  background: #f0f5ff !important;
}

.ir-guidance-btn {
  font-size: 9px !important;
  padding: 2px 5px !important;
  background: #f0f0f0;
  border: 1px solid #c0c0c0;
  cursor: pointer;
  border-radius: 2px;
  color: #333;
  transition: all 0.1s;
}

.ir-guidance-btn:hover {
  background: #e0e8f0;
  border-color: #0078d4;
}

.ir-guidance-btn.ir-active {
  background: #0078d4;
  color: white;
  border-color: #005a9e;
  font-weight: 600;
}

/* ============================================
   Phase 2.2: Board Room (RE Prestige Shop)
   ============================================ */
#board-room-rows {
  display: contents;
}

.br-header-row > * {
  background: #f5f0ff !important;
}

.br-upgrade-row > * {
  transition: background 0.1s;
}

.br-upgrade-row:hover > * {
  background: #f8f5ff !important;
}

.br-upgrade-row.br-owned > * {
  background: #f0fff0 !important;
}

.br-upgrade-row.br-locked > * {
  background: #fafafa !important;
}

.br-upgrade-row.br-locked .cell {
  color: #bbb;
}

.btn-buy-re {
  background: #7b1fa2 !important;
  color: white !important;
  border-color: #6a1b9a !important;
  font-weight: 600;
}

.btn-buy-re:hover {
  background: #6a1b9a !important;
}

.btn-buy-re:disabled {
  background: #e0d0f0 !important;
  color: #999 !important;
  border-color: #ccc !important;
  cursor: not-allowed;
}

.br-owned-badge {
  color: #217346;
  font-weight: 600;
  font-size: 11px;
}

.br-locked-badge {
  color: #bbb;
  font-size: 10px;
  font-style: italic;
}

/* ============================================
   MOBILE RESPONSIVE — Issue #34 & #35
   ============================================ */
@media (max-width: 600px) {
  /* --- #34: Grid columns E-H off-screen --- */

  /* Hide non-essential columns G (Rev/yr) and H (empty) */
  .cell-g, .cell-h, .col-g, .col-h {
    display: none !important;
  }

  /* Filler rows: hide 8th and 9th child (G and H columns) */
  .filler-row > :nth-child(8),
  .filler-row > :nth-child(9) {
    display: none !important;
  }

  /* Reduce grid to 7 columns */
  #grid-container {
    grid-template-columns: 28px minmax(60px, 1.2fr) 32px 50px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    overflow-x: auto;
  }

  /* Hide toolbar to save vertical space (it's decorative) */
  #toolbar {
    display: none;
  }

  /* Hide decorative menu items (keep only File and Help) */
  .menu-item:not(#file-menu):not([onclick="showHelp()"]) {
    display: none;
  }

  /* Compact title bar */
  #title-bar {
    height: 26px;
    padding: 0 4px;
  }

  #title-text {
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
  }

  /* Compact menu bar */
  #menu-bar {
    height: 36px;
  }

  /* Compact formula bar */
  #formula-bar {
    height: 22px;
    font-size: 10px;
  }

  #cell-ref {
    width: 40px;
    font-size: 10px;
  }

  /* Smaller row numbers */
  .row-num {
    font-size: 9px;
  }

  /* Allow button text to wrap on narrow screens */
  .cell-btn {
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    font-size: 10px;
  }

  /* Compact cell padding */
  .cell {
    padding: 2px 3px;
    font-size: 11px;
  }

  /* Ensure source names don't overflow */
  .cell-a {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Revenue breakdown: show only $/sec and $/min on mobile (#39) */
  #revenue-breakdown {
    font-size: 12px;
    padding: 4px 8px;
    gap: 6px;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  /* Hide $/hr and $/day stats and their preceding separators on mobile */
  #stat-hr,
  #stat-day {
    display: none;
  }

  /* Hide the 2nd and 3rd separators (after $/min and $/hr) */
  #revenue-breakdown .rb-sep:nth-of-type(2),
  #revenue-breakdown .rb-sep:nth-of-type(3) {
    display: none;
  }

  /* Hide debug buttons on mobile */
  #revenue-breakdown > span:last-child {
    display: none;
  }

  /* Sheet tabs: scrollable */
  #sheet-tabs {
    overflow-x: auto;
    padding: 0 4px;
  }

  .sheet-tab {
    font-size: 10px;
    padding: 3px 10px;
  }

  /* Status bar compact */
  #status-bar {
    height: 22px;
    font-size: 10px;
    padding: 0 6px;
  }

  /* Toast: fit mobile width */
  #event-toast {
    width: 90vw;
    max-width: 360px;
  }

  /* Modals: fit mobile width */
  #help-content {
    max-width: 95vw;
    max-height: 85vh;
  }

  #about-content {
    max-width: 90vw;
    padding: 20px;
  }

  #offline-content {
    max-width: 90vw;
    padding: 20px;
  }

  #series-a-content {
    max-width: 95vw;
  }

  #confirm-content {
    max-width: 90vw;
    padding: 20px;
  }

  /* Arc selection: single column on mobile */
  #arc-options {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #arc-container {
    padding: 20px;
    width: 95%;
  }

  #arc-title {
    font-size: 20px;
  }

  /* Valuation chart: hide on mobile (covers grid, hard to drag on touch) */
  #valuation-chart-container {
    display: none !important;
  }

  /* Mini-task bar: compact */
  #mini-task-bar {
    padding: 4px 8px 4px 12px;
    font-size: 11px;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* --- #35: Touch targets too small --- */

  /* All game buttons: minimum 44px touch target */
  .cell-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Max(N) links: 44px touch target */
  .cell-btn.btn-max {
    min-height: 44px;
    min-width: 36px;
    padding: 8px 6px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Grid rows: taller to accommodate buttons */
  .grid-row > * {
    min-height: 48px;
  }

  /* Header row can stay compact */
  .header-row > * {
    min-height: 28px;
  }

  /* Separator row stays compact */
  .sep-cell {
    min-height: 4px !important;
    height: 4px !important;
  }

  #row-sep > * {
    min-height: 4px !important;
  }

  /* Filler rows stay compact */
  .filler-row > * {
    min-height: 24px;
  }

  /* Menu items: 44px touch targets */
  .menu-item {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 13px;
  }

  /* Dropdown menu items: 44px touch targets */
  .menu-dropdown-item {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 13px;
  }

  /* Toast close button: 44px touch target */
  #toast-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
  }

  /* Toast action buttons: 44px */
  .toast-btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 13px;
  }

  /* Mini-task buttons: 44px */
  .mini-task-btn {
    min-height: 44px;
    padding: 8px 14px;
    font-size: 13px;
  }

  .mini-task-skip {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Modal buttons: 44px */
  #offline-ok,
  #series-a-ok,
  #about-content button,
  #confirm-buttons button {
    min-height: 44px;
    padding: 10px 20px;
    font-size: 14px;
  }

  /* Help close button */
  .help-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }

  /* Tab buttons */
  .sheet-tab {
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  /* Column headers stay compact */
  #col-headers > * {
    min-height: 22px;
  }

  /* Title bar buttons */
  .title-btn {
    min-width: 44px;
    min-height: 30px;
  }

  /* Arc option cards: larger touch targets */
  .arc-option {
    padding: 20px 16px;
    min-height: 80px;
  }

  /* Boss view: hide on mobile (Esc key doesn't work on touch) */
  /* No change needed - boss view is hidden by default */

  /* Toast countdown wrapper */
  .toast-countdown-wrapper {
    height: 44px;
  }

  .toast-countdown-label {
    font-size: 13px;
  }

  /* --- #40: Scale up text sizes for mobile readability --- */

  /* Grid cells: bump from 11px to 14px */
  .cell {
    font-size: 14px;
  }

  /* Revenue numbers in grid */
  .cell-e, .cell-f {
    font-size: 13px;
  }

  /* Button labels: readable on mobile */
  .cell-btn {
    font-size: 13px;
  }

  .cell-btn.btn-max {
    font-size: 12px;
  }

  /* Revenue breakdown bar */
  .rb-label {
    font-size: 12px;
  }

  .rb-val {
    font-size: 12px;
  }

  /* Status bar */
  #status-bar {
    font-size: 12px;
  }

  /* Sheet tabs */
  .sheet-tab {
    font-size: 12px;
  }

  /* Formula bar */
  #formula-bar {
    font-size: 12px;
  }

  #cell-ref {
    font-size: 11px;
  }

  /* Row numbers */
  .row-num {
    font-size: 10px;
  }

  /* Column headers */
  .col-header {
    font-size: 12px;
  }

  /* Toast messages */
  #event-toast {
    font-size: 14px;
  }

  /* Mini-task bar */
  #mini-task-bar {
    font-size: 13px;
  }

  /* Modal text */
  #help-content {
    font-size: 14px;
  }

  #about-content {
    font-size: 14px;
  }

  /* --- #41: Toast notifications responsive sizing --- */
  #event-toast {
    max-width: 90vw;
    width: 90vw;
  }

  #toast-body {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  #toast-actions {
    flex-wrap: wrap;
  }

  .toast-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  /* --- #42: Mobile boss key button --- */
  .mobile-boss-btn {
    /* On desktop, this is just a normal minimize button */
    /* On mobile, it triggers boss mode */
  }

  /* --- #43: Touch event support / eliminate 300ms tap delay --- */
  *, *::before, *::after {
    touch-action: manipulation;
  }

  /* --- #44: Formula bar wastes space on mobile --- */
  #formula-bar {
    display: none;
  }

  /* --- #45: Mini-task bar mobile-friendly layout --- */
  #mini-task-bar {
    max-width: 100%;
    width: 100%;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }

  #mini-task-text {
    flex: 1 1 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  #mini-task-reward {
    flex: 0 0 auto;
  }

  .mini-task-btn {
    flex: 1 1 auto;
    min-width: 80px;
  }

  .mini-task-skip {
    flex: 0 0 auto;
  }

  /* --- #50: Status bar simplified for mobile --- */
  #status-left .status-sep,
  #status-timescale {
    display: none;
  }

  #status-center {
    display: none;
  }

  #status-clicks,
  #status-zoom,
  #stock-sep {
    display: none;
  }

  /* Keep only game-date on left, time on right */
  #status-left {
    flex: 1;
  }

  #status-right {
    flex: 0 0 auto;
    gap: 4px;
  }

  /* --- #51: Modal dialogs max-width clamping --- */
  #help-content {
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
  }

  .help-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #about-content {
    max-width: 95vw;
  }

  #offline-content {
    max-width: 95vw;
  }

  #series-a-content {
    max-width: 95vw;
  }

  #confirm-content {
    max-width: 95vw;
  }

  /* --- #48: Hide filler rows on mobile to save vertical space --- */
  #filler-rows {
    display: none !important;
  }
}

/* ============================================
   LANDSCAPE MODE — Issue #49
   ============================================ */
@media (max-width: 900px) and (orientation: landscape) {
  /* Compact title bar in landscape */
  #title-bar {
    height: 22px;
    font-size: 10px;
    padding: 0 4px;
  }

  .title-btn {
    width: 36px;
    height: 22px;
    font-size: 10px;
  }

  #title-text {
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Hide menu bar entirely in landscape — vertical space is critical */
  #menu-bar {
    display: none;
  }

  /* Hide formula bar */
  #formula-bar {
    display: none;
  }

  /* Hide toolbar */
  #toolbar {
    display: none;
  }

  /* Compact column headers */
  #col-headers > * {
    height: 18px;
    min-height: 18px;
  }

  .col-header {
    font-size: 10px;
  }

  /* Compact grid rows for landscape's limited vertical space */
  .grid-row > * {
    min-height: 32px;
  }

  .header-row > * {
    min-height: 20px;
  }

  /* Compact cell buttons — still touchable but shorter */
  .cell-btn {
    min-height: 32px;
    min-width: 40px;
    padding: 4px 8px;
    font-size: 11px;
  }

  .cell-btn.btn-max {
    min-height: 32px;
    font-size: 10px;
  }

  /* Compact row numbers */
  .row-num {
    font-size: 9px;
  }

  /* Cells: slightly smaller text */
  .cell {
    font-size: 12px;
    padding: 1px 3px;
  }

  /* Compact separator */
  .sep-cell {
    height: 2px !important;
    min-height: 2px !important;
  }

  #row-sep > * {
    min-height: 2px !important;
  }

  /* Hide filler rows in landscape too */
  #filler-rows {
    display: none !important;
  }

  /* Compact revenue breakdown */
  #revenue-breakdown {
    padding: 2px 8px;
    font-size: 10px;
  }

  /* Hide $/hr and $/day in landscape */
  #stat-hr,
  #stat-day {
    display: none;
  }

  #revenue-breakdown .rb-sep:nth-of-type(2),
  #revenue-breakdown .rb-sep:nth-of-type(3) {
    display: none;
  }

  /* Compact sheet tabs */
  #sheet-tabs {
    height: 22px;
  }

  .sheet-tab {
    font-size: 10px;
    padding: 2px 10px;
    min-height: 22px;
  }

  /* Compact status bar */
  #status-bar {
    height: 18px;
    font-size: 10px;
    padding: 0 6px;
  }

  /* Simplify status bar like portrait */
  #status-center {
    display: none;
  }

  #status-clicks,
  #status-zoom,
  #stock-sep {
    display: none;
  }

  /* Mini-task bar compact */
  #mini-task-bar {
    padding: 3px 8px;
    font-size: 11px;
    gap: 6px;
    max-width: 100%;
  }

  /* Toast: fit landscape */
  #event-toast {
    max-width: 50vw;
    max-height: 90vh;
  }

  #toast-body {
    max-height: 40vh;
    overflow-y: auto;
  }

  .toast-btn {
    min-height: 36px;
  }

  /* Modals: fit landscape viewport */
  #help-content {
    max-height: 90vh;
    max-width: 70vw;
  }

  #about-content,
  #offline-content,
  #confirm-content {
    max-width: 60vw;
  }

  #series-a-content {
    max-width: 70vw;
  }

  /* Timescale banner compact */
  #timescale-banner {
    padding: 3px 12px;
    font-size: 11px;
  }

  /* Valuation chart: hide in landscape too */
  #valuation-chart-container {
    display: none !important;
  }

  /* Touch action for landscape too */
  *, *::before, *::after {
    touch-action: manipulation;
  }

  /* Overscroll prevention */
  html, body {
    overscroll-behavior: none;
  }
}
