/* Classic Mac Arcade (.github.io) + Authentic Macintosh System 7 Styling */

:root {
  --bg-dark: #111318;
  --bg-surface: #1a1d24;
  --border-subtle: rgba(255, 255, 255, 0.09);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --mac-bezel: #d8d5cb;
  --mac-bezel-shadow: #9b988e;
  --mac-bezel-highlight: #f4f2ec;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-dark);
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  color: var(--text-main);
}

.arcade-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   Minimal .github.io Top Navigation Bar
   ========================================================================= */

.arcade-topbar {
  height: 48px;
  padding: 0 18px;
  background: rgba(20, 23, 30, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 60;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 11px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.brand-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.brand-count {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
}

.topbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
}

.game-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-tab {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s;
}

.game-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.game-tab.active {
  color: #ffffff;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.scale-group {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 2px;
}

.top-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  cursor: pointer;
}

.top-pill:hover {
  color: var(--text-main);
}

.top-pill.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.top-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.top-btn:hover {
  background: rgba(255, 255, 255, 0.11);
}

.top-btn.muted {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

/* =========================================================================
   Main Stage & Macintosh Color Monitor Frame
   ========================================================================= */

.arcade-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 16px;
  gap: 14px;
}

.mac-monitor {
  background: var(--mac-bezel);
  border-top: 2px solid var(--mac-bezel-highlight);
  border-left: 2px solid var(--mac-bezel-highlight);
  border-right: 3px solid var(--mac-bezel-shadow);
  border-bottom: 4px solid var(--mac-bezel-shadow);
  border-radius: 14px;
  padding: 16px 18px 12px 18px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px #706e66;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #000000;
  font-family: "Chicago", "Charcoal", "Geneva", -apple-system, BlinkMacSystemFont, sans-serif;
  transition: width 0.2s ease, max-width 0.2s ease;
}

/* Scale modes for 512x320 screen */
.mac-monitor.scale-fit {
  width: min(94vw, calc((100vh - 150px) * 1.52));
  max-width: 960px;
}

.mac-monitor.scale-2x {
  width: 1068px;
  max-width: 96vw;
}

.mac-monitor.scale-1x {
  width: 556px;
  max-width: 96vw;
}

.mac-monitor:fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  border-radius: 0;
  justify-content: center;
  align-items: center;
  background: #111111;
  border: none;
}

.mac-monitor:fullscreen .mac-screen {
  width: min(96vw, calc((92vh - 40px) * 1.6));
}

.mac-monitor:fullscreen .mac-bezel-chin {
  display: none;
}

/* CRT Inner Screen Frame */
.mac-screen {
  background: #000000;
  border-top: 3px solid #6b6961;
  border-left: 3px solid #6b6961;
  border-right: 3px solid #efede6;
  border-bottom: 3px solid #efede6;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px #000000;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* =========================================================================
   Authentic System 7 Menu Bar
   ========================================================================= */

.mac-menubar {
  height: 22px;
  background: #ffffff;
  border-bottom: 1px solid #000000;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  position: relative;
  z-index: 50;
}

.menubar-left {
  display: flex;
  align-items: stretch;
}

.menubar-right {
  display: flex;
  align-items: center;
  padding-right: 4px;
  font-size: 12px;
}

.menu-root {
  position: relative;
  display: flex;
  align-items: stretch;
}

.menu-title {
  padding: 0 10px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.menu-title.apple-logo {
  font-size: 15px;
  color: #d92b2b;
  padding: 0 11px;
}

.menu-root.open > .menu-title {
  background: #000000;
  color: #ffffff;
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: 22px;
  left: 0;
  min-width: 195px;
  background: #ffffff;
  border: 1px solid #000000;
  box-shadow: 2px 2px 0 #000000;
  padding: 2px 0;
  z-index: 100;
}

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

.menu-item {
  display: flex;
  align-items: center;
  padding: 3px 10px 3px 6px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
}

.menu-item .check {
  width: 16px;
  display: inline-block;
  text-align: center;
  font-weight: bold;
}

.menu-item .label {
  flex: 1;
}

.menu-item .shortcut {
  margin-left: 18px;
  font-size: 11px;
}

.menu-item:hover:not(.disabled) {
  background: #000000;
  color: #ffffff;
}

.menu-item.disabled {
  color: #888888;
  cursor: default;
}

.menu-divider {
  height: 1px;
  background: #888888;
  margin: 3px 0;
}

/* =========================================================================
   512x320 Game Canvas Viewport & Boot Card
   ========================================================================= */

.screen-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 512 / 320;
  background: #000000;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: default;
}

.boot-overlay {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      #b8b8b8 0px,
      #b8b8b8 2px,
      #dedede 2px,
      #dedede 4px
    );
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30;
  cursor: pointer;
}

.boot-overlay.hidden {
  display: none;
}

.boot-dialog {
  background: #ffffff;
  border: 2px solid #000000;
  outline: 3px solid #ffffff;
  box-shadow: 4px 4px 0 #000000;
  padding: 22px 32px;
  text-align: center;
  max-width: 360px;
}

.boot-mac-icon {
  font-size: 32px;
  margin-bottom: 6px;
  background: linear-gradient(
    to bottom,
    #61bb46 0%, #61bb46 16%,
    #fdb827 16%, #fdb827 33%,
    #f5821f 33%, #f5821f 50%,
    #e03a3e 50%, #e03a3e 66%,
    #963d97 66%, #963d97 83%,
    #009ddc 83%, #009ddc 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.boot-dialog h1 {
  margin: 0 0 6px 0;
  font-family: "Garamond", "Times New Roman", serif;
  font-weight: normal;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.boot-sub {
  margin: 0 0 4px 0;
  font-size: 12px;
  font-weight: bold;
  color: #222222;
}

.boot-copy {
  margin: 0 0 16px 0;
  font-size: 11px;
  color: #666666;
}

/* =========================================================================
   Macintosh Bezel Chin & Shortcut Strip
   ========================================================================= */

.mac-bezel-chin {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
}

.mac-badge {
  display: flex;
  align-items: center;
  gap: 7px;
}

.rainbow-apple {
  font-size: 16px;
  background: linear-gradient(
    to bottom,
    #61bb46 0%, #61bb46 16%,
    #fdb827 16%, #fdb827 33%,
    #f5821f 33%, #f5821f 50%,
    #e03a3e 50%, #e03a3e 66%,
    #963d97 66%, #963d97 83%,
    #009ddc 83%, #009ddc 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mac-model {
  font-family: "Garamond", "Times New Roman", serif;
  font-size: 14px;
  font-style: italic;
  color: #3a3834;
  letter-spacing: 0.2px;
}

.power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.6),
    0 0 6px rgba(34, 197, 94, 0.7);
}

.shortcut-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.shortcut-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 9px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.shortcut-pill:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
}

.shortcut-hint {
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.shortcut-strip kbd {
  background: rgba(255, 255, 255, 0.09);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10.5px;
  color: var(--text-main);
}

/* =========================================================================
   In-Screen Classic Macintosh Modal Windows
   ========================================================================= */

.mac-modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 40;
  padding: 16px;
}

.mac-modal.hidden {
  display: none;
}

.mac-window {
  background: #ffffff;
  border: 1px solid #000000;
  box-shadow: 3px 3px 0 #000000;
  display: flex;
  flex-direction: column;
  max-height: 92%;
  width: 100%;
}

.help-window {
  max-width: 580px;
}

.dialog-window {
  max-width: 420px;
}

.cert-window {
  max-width: 600px;
}

.mac-titlebar {
  height: 20px;
  background:
    repeating-linear-gradient(
      to bottom,
      #ffffff 0px,
      #ffffff 1px,
      #000000 1px,
      #000000 2px
    );
  border-bottom: 1px solid #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 8px;
}

.mac-window-title {
  background: #ffffff;
  padding: 0 8px;
  font-size: 12px;
  font-weight: bold;
}

.mac-close-box {
  position: absolute;
  left: 6px;
  width: 11px;
  height: 11px;
  background: #ffffff;
  border: 1px solid #000000;
  padding: 0;
  cursor: pointer;
}

.mac-close-box:hover {
  background: #000000;
}

.mac-window-content {
  padding: 14px;
  overflow-y: auto;
  font-size: 12px;
}

.help-text-body {
  margin: 0;
  white-space: pre-wrap;
  font-family: "Geneva", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
  background: #fafafa;
  border: 1px solid #000000;
  user-select: text;
  -webkit-user-select: text;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 10px 12px;
  align-items: center;
}

.form-grid input[type="number"] {
  border: 1px solid #000000;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
}

.profiles-list {
  border: 1px solid #000000;
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.profile-row {
  padding: 6px 10px;
  border-bottom: 1px solid #dddddd;
  cursor: pointer;
  font-weight: bold;
}

.profile-row:hover {
  background: #000000;
  color: #ffffff;
}

.dialog-caption {
  margin: 0 0 8px 0;
}

.import-row {
  display: flex;
  justify-content: flex-start;
}

.hidden-file-input {
  display: none;
}

.cert-scroll {
  display: flex;
  justify-content: center;
  background: #d0d0d0;
  max-height: 340px;
  overflow-y: auto;
}

#cert-canvas {
  background: #ffffff;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  height: auto;
}

.mac-dialog-footer {
  padding: 10px 14px;
  border-top: 1px solid #cccccc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f5f5f5;
}

.mac-btn {
  background: #ffffff;
  color: #000000;
  border: 1px solid #000000;
  border-radius: 4px;
  padding: 4px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 1px 1px 0 #000000;
}

.mac-btn.primary-btn {
  border: 2px solid #000000;
  outline: 1px solid #000000;
  outline-offset: 2px;
}

.mac-btn:active {
  background: #000000;
  color: #ffffff;
}

/* =========================================================================
   Game Library Drawer / Modal (.github.io Multi-Game Hub)
   ========================================================================= */

.library-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 200;
}

.library-overlay.hidden {
  display: none;
}

.library-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  padding: 22px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.library-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.library-header h2 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
}

.library-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.library-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.library-close-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.12);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.game-item-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  color: var(--text-main);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.game-item-card:hover:not(.placeholder) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
}

.game-item-card.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.45);
}

.game-item-card.placeholder {
  border-style: dashed;
  opacity: 0.7;
}

.game-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.game-item-badge {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.game-item-title {
  font-size: 15px;
  font-weight: 600;
}

.game-item-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.game-item-desc code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 11.5px;
}
