/* Arcade windows size from their own content area, not the outer browser viewport. */
.snake-window .app-body,
.minesweeper-window .app-body,
.solitaire-window .app-body,
.rpg-window .app-body {
  container-type: size;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.snake-window .game-app,
.minesweeper-window .game-app,
.solitaire-window .game-app,
.rpg-window .game-app {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.snake-window .snake-layout {
  min-height: calc(100% - 54px);
  grid-template-columns: minmax(0, var(--play-square)) minmax(168px, 220px);
  align-content: center;
  padding: clamp(12px, 2.5cqw, 34px);
}
.snake-window .snake-stage { width: 100%; max-width: none; box-sizing: border-box; }
.snake-window #snake-canvas { width: 100%; max-width: none; height: auto; }

.minesweeper-window .mine-board-wrap { display: grid; place-items: center; min-height: 0; }
.minesweeper-window .mine-grid { width: var(--mine-square); max-width: 100%; min-width: 0; }

.solitaire-window .solitaire-board {
  --card-w: var(--sol-card-w);
  min-height: 100%;
  overflow: auto;
}
.solitaire-window .tableau {
  width: 100%;
  min-width: calc(var(--card-w) * 7 + 72px);
}

.game-is-compact .snake-layout {
  grid-template-columns: 1fr;
  align-content: start;
}
.game-is-compact .snake-stage { justify-self: center; }
.game-is-compact .snake-side { grid-template-columns: auto 1fr; }
.game-is-compact .snake-side > p { display: none; }
.game-is-tiny .snake-side { grid-template-columns: 1fr; }
.game-is-tiny .game-toolbar { position: sticky; z-index: 5; top: 0; }

/* Darkness Quest */
.dq-app {
  --dq-panel: rgba(16, 8, 19, .94);
  --dq-line: #f2d7a4;
  --dq-gold: #ffd166;
  --dq-good: #c9ff45;
  --dq-cyan: #48f0e6;
  --dq-pink: #f32b8f;
  --dq-orange: #ff7748;
  width: 100%;
  height: 100%;
  min-height: 100%;
  color: #fff7e8;
  background: #09070d;
  font-family: var(--mono);
}
.dq-app button { touch-action: manipulation; }
.dq-app button:focus-visible { outline: 3px solid var(--dq-cyan); outline-offset: 2px; }

.dq-title {
  height: 100%;
  min-height: 430px;
  display: grid;
  place-items: center;
  padding: clamp(18px, 5cqw, 56px);
  background-image: linear-gradient(rgba(5, 2, 8, .12), rgba(5, 2, 8, .78)), url('/assets/rpg/rpg_title.png');
  background-position: center;
  background-size: cover;
}
.dq-title-card {
  width: min(560px, 94%);
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: clamp(22px, 4cqw, 44px);
  border: 2px solid var(--dq-line);
  background: rgba(10, 5, 13, .82);
  box-shadow: 10px 10px 0 #7e1f5b;
  text-align: center;
  text-shadow: 2px 2px #000;
}
.dq-title-card > p { margin: 0; color: var(--dq-orange); font: 900 11px var(--mono); }
.dq-title-card h1 { margin: 0; color: var(--dq-gold); font: 900 clamp(42px, 8cqw, 78px)/.82 var(--mono); }
.dq-title-card h1 span { color: var(--dq-pink); font-size: .46em; }
.dq-title-card > span { max-width: 440px; color: #f7eadb; font: 900 12px/1.55 var(--mono); }
.dq-title-card > small { color: #b8d8d4; font: 10px/1.5 var(--mono); }

.dq-primary,
.dq-command,
.dq-choice,
.dq-shop-item,
.dq-inventory-item {
  min-height: 42px;
  padding: 9px 13px;
  color: #fff;
  border: 2px solid #25111f;
  background: var(--dq-pink);
  box-shadow: inset 1px 1px #ff9bc9;
  cursor: pointer;
  font: 900 11px var(--mono);
}
.dq-primary:hover,
.dq-command:hover,
.dq-choice:hover,
.dq-shop-item:hover,
.dq-inventory-item:hover { color: #170b15; background: var(--dq-good); }
.dq-primary { min-width: 210px; color: #160b14; background: var(--dq-orange); }
.dq-command:disabled,
.dq-shop-item:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.7); }

.dq-class-screen,
.dq-map-screen,
.dq-place-screen,
.dq-inventory-screen {
  min-height: 100%;
  display: grid;
  align-content: center;
  gap: clamp(18px, 3cqh, 30px);
  padding: clamp(20px, 4cqw, 48px);
  background: radial-gradient(circle at 50% 0, #352139 0, #100913 70%);
}
.dq-screen-header { display: grid; gap: 7px; text-align: center; }
.dq-screen-header p { margin: 0; color: var(--dq-orange); font: 900 11px var(--mono); }
.dq-screen-header h2 { margin: 0; color: #fff7e8; font: italic clamp(31px, 5cqw, 52px)/1 var(--editorial); }
.dq-screen-header span { color: #cbbbc3; font: 12px/1.5 var(--mono); }

.dq-class-grid,
.dq-map-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 2cqw, 18px); }
.dq-choice {
  min-height: 210px;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 11px;
  padding: clamp(15px, 2.5cqw, 24px);
  color: #fff7e8;
  border: 1px solid #8a526d;
  background: #21121f;
  box-shadow: 7px 7px 0 var(--dq-pink);
  text-align: center;
}
.dq-choice:nth-child(2) { box-shadow-color: var(--dq-cyan); }
.dq-choice:nth-child(3) { box-shadow-color: var(--dq-orange); }
.dq-choice b { width: 62px; height: 62px; display: grid; place-items: center; color: #160b14; background: var(--dq-good); font: 900 28px var(--mono); }
.dq-choice strong { font: 900 15px var(--mono); }
.dq-choice span { color: #d5c5cd; font: 11px/1.5 var(--mono); }
.dq-choice small { color: var(--dq-cyan); font: 10px/1.45 var(--mono); }
.dq-choice em { margin-top: auto; padding: 6px 8px; color: #160b14; background: var(--dq-orange); font: 900 10px var(--mono); font-style: normal; }

.dq-hud {
  min-height: 64px;
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) minmax(100px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 13px;
  color: var(--dq-gold);
  border-bottom: 2px solid #c44873;
  background: rgba(9, 5, 12, .96);
  font: 900 10px var(--mono);
}
.dq-hero-id { display: grid; gap: 3px; }
.dq-hero-id strong { color: var(--dq-cyan); }
.dq-meter { display: grid; gap: 4px; }
.dq-meter i { height: 9px; display: block; border: 1px solid #f4e8d7; background: #421520; }
.dq-meter i b { height: 100%; display: block; background: #ff486a; transition: width .2s; }
.dq-meter.is-mp i b { background: var(--dq-cyan); }
.dq-wallet { text-align: right; }

.dq-map-status { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.dq-map-status span { padding: 6px 9px; color: #160b14; background: var(--dq-cyan); font: 900 10px var(--mono); }
.dq-place-layout { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(330px, 1.2fr); gap: clamp(18px, 4cqw, 46px); align-items: stretch; }
.dq-place-art {
  min-height: 330px;
  display: grid;
  align-content: end;
  padding: 24px;
  border: 2px solid var(--dq-line);
  background: linear-gradient(rgba(8, 3, 11, .1), rgba(8, 3, 11, .72)), url('/assets/rpg/rpg_town.png') center/cover;
  box-shadow: 8px 8px 0 #782058;
  text-shadow: 2px 2px #000;
}
.dq-place-art.is-castle { background-image: linear-gradient(rgba(8, 3, 11, .18), rgba(8, 3, 11, .8)), url('/assets/rpg/rpg_title.png'); }
.dq-place-art p { margin: 0; color: var(--dq-orange); font: 900 11px var(--mono); }
.dq-place-art h2 { margin: 4px 0; font: italic clamp(30px, 4cqw, 48px)/1 var(--editorial); }
.dq-place-art span { color: #d8ebe8; font: 11px/1.5 var(--mono); }
.dq-place-panel { display: grid; align-content: start; gap: 14px; padding: clamp(18px, 3cqw, 30px); border: 2px solid var(--dq-line); background: var(--dq-panel); box-shadow: 8px 8px 0 #782058; }
.dq-place-panel > p { min-height: 44px; margin: 0; color: #e5d8df; font: 12px/1.55 var(--mono); }
.dq-town-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dq-town-actions .dq-command:first-child { grid-column: 1 / -1; color: #170b15; background: var(--dq-orange); }

.dq-shop-list,
.dq-inventory-list { display: grid; gap: 8px; }
.dq-shop-item,
.dq-inventory-item { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; text-align: left; }
.dq-shop-item span,
.dq-inventory-item span { color: #ffe5f0; font: 10px/1.4 var(--mono); }
.dq-shop-item b,
.dq-inventory-item b { grid-row: 1 / 3; grid-column: 2; align-self: center; color: #170b15; }
.dq-equipped { color: var(--dq-good) !important; }

.dq-game-screen { height: 100%; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.dq-game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) clamp(300px, 29cqw, 440px);
  gap: 0;
  background: #08070c;
}
.dq-viewport-wrap { min-width: 0; min-height: 0; display: grid; align-content: center; padding: clamp(8px, 1.6cqw, 18px); background: #05060a; }
.dq-viewport {
  position: relative;
  width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border: 2px solid var(--dq-line);
  background: #020306;
  image-rendering: pixelated;
  box-shadow: 0 0 30px rgba(72, 240, 230, .12);
}
.dq-side-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: clamp(11px, 1.7cqw, 18px);
  overflow: auto;
  border-left: 2px solid #c44873;
  background: #120b15;
}
.dq-location { display: flex; justify-content: space-between; gap: 12px; color: var(--dq-cyan); font: 900 10px/1.4 var(--mono); }
.dq-message { min-height: 52px; margin: 0; padding: 11px; color: #fff4e7; border: 1px solid #765164; background: #1c111d; font: 11px/1.55 var(--mono); }
.dq-explore-actions,
.dq-battle-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; align-content: start; }
.dq-explore-actions .dq-command,
.dq-battle-actions .dq-command { min-height: 52px; display: grid; grid-template-columns: 25px 1fr; align-items: center; gap: 7px; text-align: left; }
.dq-command kbd { color: #170b15; font: 900 14px var(--mono); }
.dq-command span { display: grid; gap: 3px; }
.dq-command small { color: #ffe0ed; font: 9px/1.35 var(--mono); }
.dq-command:hover small { color: #38232e; }
.dq-dpad { display: grid; grid-template: repeat(3, 42px) / repeat(3, 42px); justify-content: center; gap: 4px; }
.dq-dpad button { min-width: 0; min-height: 0; padding: 0; }
.dq-dpad button:nth-child(1) { grid-area: 1 / 2; }
.dq-dpad button:nth-child(2) { grid-area: 2 / 1; }
.dq-dpad button:nth-child(3) { grid-area: 2 / 2; }
.dq-dpad button:nth-child(4) { grid-area: 2 / 3; }
.dq-dpad button:nth-child(5) { grid-area: 3 / 2; }
.dq-mini-map { display: grid; grid-template-columns: repeat(var(--map-w), 11px); justify-content: center; gap: 1px; padding: 8px; border: 1px solid #5f4454; background: #08070c; }
.dq-mini-map i { width: 11px; height: 11px; display: block; background: #171019; }
.dq-mini-map i.is-seen { background: #3e6d6b; }
.dq-mini-map i.is-wall { background: #5a354a; }
.dq-mini-map i.is-player { background: var(--dq-good); box-shadow: 0 0 5px var(--dq-good); }
.dq-mini-map i.is-exit { background: var(--dq-orange); }
.dq-battle-tag { color: var(--dq-orange); font: 900 10px var(--mono); }
.dq-enemy-meter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  color: var(--dq-cyan);
  font: 900 10px var(--mono);
}
.dq-enemy-meter i {
  grid-column: 1 / -1;
  height: 14px;
  display: block;
  border: 1px solid #f4e8d7;
  background: #2f1324;
}
.dq-enemy-meter i b { height: 100%; display: block; background: linear-gradient(90deg, var(--dq-pink), var(--dq-orange)); transition: width .18s; }
.dq-enemy-meter em { grid-area: 1 / 2; color: var(--dq-gold); font-style: normal; }
.dq-loot-card { padding: 12px; color: #170b15; border: 2px solid #170b15; background: var(--dq-good); box-shadow: 5px 5px 0 var(--dq-pink); font: 900 10px/1.5 var(--mono); }

.game-is-roomy .dq-dpad { grid-template: repeat(3, 48px) / repeat(3, 48px); }
.game-is-roomy .dq-mini-map { grid-template-columns: repeat(var(--map-w), 13px); }
.game-is-roomy .dq-mini-map i { width: 13px; height: 13px; }

.game-is-compact .dq-hud { grid-template-columns: 1fr 1fr; }
.game-is-compact .dq-wallet { grid-column: 1 / -1; text-align: left; }
.game-is-compact .dq-game-screen { height: auto; min-height: 100%; overflow: auto; }
.game-is-compact .dq-game-layout { grid-template-columns: 1fr; }
.game-is-compact .dq-viewport-wrap { min-height: 280px; }
.game-is-compact .dq-side-panel { overflow: visible; border-top: 2px solid #c44873; border-left: 0; }
.game-is-compact .dq-class-grid,
.game-is-compact .dq-map-grid,
.game-is-compact .dq-place-layout { grid-template-columns: 1fr; }
.game-is-compact .dq-choice { min-height: 150px; }
.game-is-compact .dq-place-art { min-height: 220px; }
.game-is-tiny .dq-place-art { display: none; }
.game-is-tiny .dq-explore-actions,
.game-is-tiny .dq-battle-actions,
.game-is-tiny .dq-town-actions { grid-template-columns: 1fr; }
.game-is-tiny .dq-town-actions .dq-command:first-child { grid-column: auto; }

@container (max-width: 620px) {
  .dq-title-card h1 { font-size: 42px; }
  .dq-class-grid, .dq-map-grid, .dq-place-layout { grid-template-columns: 1fr; }
  .dq-choice { min-height: 145px; }
}

@media (max-width: 720px) {
  .snake-window .app-body,
  .minesweeper-window .app-body,
  .solitaire-window .app-body,
  .rpg-window .app-body { overflow: auto; }
  .dq-game-screen { height: auto; min-height: 100%; overflow: auto; }
  .dq-game-layout { grid-template-columns: 1fr; }
  .dq-viewport-wrap { min-height: 250px; }
  .dq-side-panel { overflow: visible; border-top: 2px solid #c44873; border-left: 0; }
}
