/* ============================================================
   WARM RETRO WOODEN ARCADE & LOUNGE AESTHETIC
   Clean, spacious game screen — NEVER CLIPPED
   Sidebar games collection on the RIGHT with authentic covers
============================================================ */

:root {
  --wood-deep: #160f0a;
  --wood-dark: #24160e;
  --wood-mid: #382417;
  --wood-panel: #4a3020;
  --wood-light: #61402b;
  --wood-bevel-light: #7c5438;
  --wood-bevel-dark: #120a06;

  --brass-bright: #f0c868;
  --brass-mid: #cfa042;
  --brass-dark: #8c641c;
  --brass-shadow: #452f08;

  --ivory-key: #f7f1e3;
  --ivory-key-shadow: #b3a58b;
  --ivory-text: #2c1d11;

  --amber-glow: #ffaa33;
  --amber-light: #ffe082;
  --text-light: #fdfaf5;
  --text-muted: #d9c7b4;
  --text-dim: #998370;

  --font-retro: "Courier New", Courier, monospace;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  background-color: var(--wood-deep);
  color: var(--text-light);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 50% 15%, rgba(255, 170, 51, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 80% 85%, rgba(124, 84, 56, 0.15) 0%, transparent 50%),
    linear-gradient(180deg, #1d120c 0%, #110b07 100%);
  background-attachment: fixed;
}

/* ============================================================
   TOLL GATE / PASSWORD LOCK SCREEN OVERLAY
============================================================ */
.tollgate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 8, 5, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.tollgate-overlay.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tollgate-box {
  background: linear-gradient(145deg, #382417, #24160e);
  border: 3px solid var(--brass-mid);
  box-shadow: 
    0 16px 40px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 0 20px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  padding: 2.25rem 2rem;
  text-align: center;
  position: relative;
  animation: boxPop 0.35s ease-out;
}

@keyframes boxPop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.brass-plaque {
  display: inline-block;
  background: linear-gradient(180deg, var(--brass-bright) 0%, var(--brass-mid) 60%, var(--brass-dark) 100%);
  color: #2b180a;
  padding: 0.35rem 1.25rem;
  border-radius: 4px;
  font-family: var(--font-retro);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  margin-bottom: 0.8rem;
}

.tollgate-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brass-bright);
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.tollgate-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.gate-input {
  width: 100%;
  background: #180f09;
  border: 2px solid var(--wood-light);
  border-radius: var(--radius-md);
  padding: 0.85rem 3rem 0.85rem 1rem;
  color: var(--brass-bright);
  font-family: var(--font-retro);
  font-size: 1.1rem;
  outline: none;
  transition: all 0.2s;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.8);
}

.gate-input:focus {
  border-color: var(--brass-bright);
  box-shadow: 0 0 12px rgba(240, 200, 104, 0.35), inset 0 2px 6px rgba(0,0,0,0.8);
}

.toggle-pwd-btn {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.toggle-pwd-btn:hover {
  opacity: 1;
}

.gate-error {
  font-family: var(--font-retro);
  font-size: 0.8rem;
  color: #ff5544;
  font-weight: bold;
}

.gate-error.hidden {
  display: none;
}

.brass-unlock-btn {
  background: linear-gradient(180deg, #f5d47a 0%, #d4a037 60%, #9e7118 100%);
  color: #241407;
  border: 1px solid var(--brass-shadow);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 4px 0 #573a08, 0 6px 14px rgba(0, 0, 0, 0.5);
  transition: all 0.15s ease;
  user-select: none;
}

.brass-unlock-btn:hover {
  background: linear-gradient(180deg, #ffe08f 0%, #e3af46 60%, #b38222 100%);
  box-shadow: 0 4px 0 #573a08, 0 8px 18px rgba(240, 200, 104, 0.3);
  transform: translateY(-1px);
}

.brass-unlock-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #573a08, 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   RETRO HEADER
============================================================ */
.arcade-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.arcade-app.locked {
  filter: blur(8px);
  pointer-events: none;
}

header.retro-header {
  background: linear-gradient(180deg, #301d12 0%, #20130a 100%);
  border-bottom: 3px solid var(--brass-dark);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.65rem 1.25rem;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.retro-badge {
  background: linear-gradient(180deg, var(--brass-bright) 0%, var(--brass-dark) 100%);
  color: #1e1005;
  font-family: var(--font-retro);
  font-size: 0.65rem;
  font-weight: 900;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--brass-shadow);
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  letter-spacing: 0.08em;
}

.site-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.wood-btn {
  background: linear-gradient(180deg, #442b1a 0%, #26160d 100%);
  border: 1px solid var(--brass-dark);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s;
}

.wood-btn:hover {
  color: #fff;
  border-color: var(--brass-bright);
}

/* ============================================================
   MAIN TWO-COLUMN LAYOUT
   Left: Game + Controls
   Right: Games Library Sidebar with Images
============================================================ */
main.arcade-main-layout {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 1.5rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  align-items: start;
}

@media (max-width: 1024px) {
  main.arcade-main-layout {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   LEFT COLUMN: GAME CABINET & UNCLIPPED STAGE
============================================================ */
.game-column {
  min-width: 0;
}

.wooden-desk-frame {
  background: linear-gradient(180deg, #2b1a10 0%, #1c1008 100%);
  border: 4px solid var(--brass-dark);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.1);
  overflow: visible;
  display: flex;
  flex-direction: column;
}

/* Game Title & Controls Header Bar */
.desk-header {
  background: linear-gradient(180deg, #3c2415 0%, #29170c 100%);
  border-bottom: 2px solid var(--brass-dark);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.game-identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.game-emoji {
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.current-game-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}

.current-game-tagline {
  font-size: 0.85rem;
  color: var(--brass-bright);
}

.desk-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.arcade-btn {
  background: linear-gradient(180deg, #4a3020 0%, #29180c 100%);
  border: 1px solid var(--brass-mid);
  color: var(--text-light);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 3px 0 var(--brass-shadow), 0 4px 8px rgba(0,0,0,0.4);
  transition: all 0.12s ease;
  user-select: none;
}

.arcade-btn:hover {
  background: linear-gradient(180deg, #5c3c26 0%, #352010 100%);
  border-color: var(--brass-bright);
  color: #fff;
}

.arcade-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--brass-shadow);
}

.arcade-btn.btn-brass {
  background: linear-gradient(180deg, var(--brass-bright) 0%, var(--brass-mid) 60%, var(--brass-dark) 100%);
  color: #241407;
  border-color: var(--brass-shadow);
}

.arcade-btn.btn-brass:hover {
  background: linear-gradient(180deg, #ffe08f 0%, #e3af46 60%, #b38222 100%);
  color: #1a0e05;
}

.arcade-btn.is-muted {
  background: linear-gradient(180deg, #571e16 0%, #2b0b07 100%) !important;
  border-color: #d9534f !important;
  color: #ffc2c0 !important;
  box-shadow: 0 3px 0 #180504, 0 0 10px rgba(217, 83, 79, 0.3) !important;
}

.arcade-btn.is-muted:hover {
  background: linear-gradient(180deg, #6e261c 0%, #3a100a 100%) !important;
  border-color: #ff7875 !important;
  color: #ffffff !important;
}

/* ============================================================
   CLEAN & UNCLIPPED GAME VIEWPORT
   NO CRT lines, NO height clipping!
============================================================ */
.game-stage-wrapper {
  position: relative;
  background: #000;
  width: 100%;
  /* Dynamic natural aspect ratios */
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Crucial: DO NOT clamp with fixed max-height that causes vertical clipping */
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
}

.game-stage-wrapper.ratio-575-430 {
  aspect-ratio: 575 / 430;
}

.game-stage-wrapper.ratio-550-400 {
  aspect-ratio: 550 / 400;
}

.game-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-viewport ruffle-player {
  width: 100%;
  height: 100%;
  display: block;
}

/* Loading & Error Overlays */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18, 11, 7, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 2rem;
  text-align: center;
  transition: opacity 0.25s ease;
}

.screen-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.warm-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(240, 200, 104, 0.2);
  border-top-color: var(--brass-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-family: var(--font-retro);
  font-size: 1rem;
  font-weight: bold;
  color: var(--brass-bright);
  margin-bottom: 0.35rem;
}

.loader-sub {
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* ============================================================
   TACTILE RETRO CONTROL DECK (Directly Below Game)
============================================================ */
.control-deck {
  background: linear-gradient(180deg, #22140a 0%, #180d07 100%);
  border-top: 3px solid var(--brass-dark);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.deck-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.75rem;
}

.deck-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.deck-brass-tag {
  background: linear-gradient(180deg, var(--brass-bright) 0%, var(--brass-dark) 100%);
  color: #241306;
  font-family: var(--font-retro);
  font-size: 0.75rem;
  font-weight: 900;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.deck-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
}

.deck-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brass-bright);
  background: rgba(240, 200, 104, 0.12);
  border: 1px solid rgba(240, 200, 104, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

/* Tactile Ivory/Brass Keycaps Grid */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.key-card {
  background: #140b06;
  border: 1px solid #331e11;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: transform 0.12s, border-color 0.12s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.key-card:hover {
  border-color: var(--brass-mid);
  transform: translateY(-2px);
}

/* Tactile 3D Ivory Mechanical Keycap */
.keycap {
  background: linear-gradient(180deg, #fbf7ee 0%, #ebe0cb 100%);
  border: 1px solid var(--ivory-key-shadow);
  box-shadow: 0 3px 0 #8f7d63, 0 4px 8px rgba(0,0,0,0.4), inset 0 1px 0 #ffffff;
  color: #2e1a0b;
  font-family: var(--font-retro);
  font-size: 0.85rem;
  font-weight: 900;
  padding: 0.4rem 0.65rem;
  border-radius: 5px;
  min-width: 44px;
  text-align: center;
  flex-shrink: 0;
  user-select: none;
  letter-spacing: 0.05em;
}

.key-desc {
  display: flex;
  flex-direction: column;
}

.key-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
}

.key-action {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Mission & How To Play Deck Guides */
.deck-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: rgba(14, 8, 4, 0.75);
  border: 1px solid #331d10;
  border-radius: var(--radius-sm);
  padding: 1.1rem;
}

@media (max-width: 768px) {
  .deck-guide {
    grid-template-columns: 1fr;
  }
}

.guide-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.guide-label {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--brass-bright);
}

.guide-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================================
   RIGHT COLUMN: SIDEBAR GAMES LIST WITH IMAGES
============================================================ */
.sidebar-column {
  position: sticky;
  top: 4.5rem;
}

.sidebar-frame {
  background: linear-gradient(180deg, #27180e 0%, #1a0f08 100%);
  border: 3px solid var(--brass-dark);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--brass-dark);
  padding-bottom: 0.65rem;
}

.sidebar-brass-badge {
  background: linear-gradient(180deg, var(--brass-bright) 0%, var(--brass-dark) 100%);
  color: #241407;
  font-family: var(--font-retro);
  font-size: 0.65rem;
  font-weight: 900;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.sidebar-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.03em;
}

.sidebar-count {
  font-size: 0.78rem;
  color: var(--brass-bright);
  font-weight: bold;
}

.sidebar-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Sidebar Game Cards List */
.sidebar-games-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - 12rem);
  overflow-y: auto;
  padding-right: 0.3rem;
  scrollbar-width: thin;
  scrollbar-color: var(--brass-dark) transparent;
}

.sidebar-card {
  background: #190e07;
  border: 1px solid #3d2314;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.sidebar-card:hover {
  background: #2b170c;
  border-color: var(--brass-bright);
  transform: translateX(-3px);
  box-shadow: 0 4px 12px rgba(240, 200, 104, 0.2);
}

.sidebar-card.active {
  background: linear-gradient(135deg, #3d2414 0%, #201108 100%);
  border: 2px solid var(--brass-bright);
  box-shadow: 0 0 14px rgba(240, 200, 104, 0.35);
}

.sidebar-card-img-wrap {
  width: 90px;
  height: 64px;
  border-radius: 5px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.sidebar-card:hover .sidebar-card-img {
  transform: scale(1.05);
}

.sidebar-card-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}

.sidebar-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.sidebar-card-genre {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--brass-bright);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-card-year {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.sidebar-card-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-card-status {
  font-size: 0.7rem;
  color: var(--brass-mid);
  margin-top: 0.2rem;
  display: none;
}

.sidebar-card.active .sidebar-card-status {
  display: inline-block;
  color: var(--brass-bright);
  font-weight: bold;
}

/* ============================================================
   FOOTER
============================================================ */
footer.retro-footer {
  border-top: 2px solid var(--brass-dark);
  background: #120a06;
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: auto;
}

/* Fullscreen support */
.game-stage-wrapper:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: none !important;
  border: none;
}

.game-stage-wrapper:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: none !important;
  border: none;
}
