/*
 * Game Info: the arcade cabinet (marquee, screen with High Scores / Demo / Graphs, control panel) beside a compact
 * info panel. Colours and fonts come from tokens.css; the cabinet's metal and bezel tones are local to this page.
 *
 * Orientation: .layout carries .is-portrait or .is-landscape (server hint, then the browser's loadedmetadata). It sets
 * three variables that everything else follows:
 *   --cab-max     how wide the cabinet may get (narrower for a portrait screen, so the info panel stays beside it)
 *   --marquee-h   marquee height (landscape screens are short, so the marquee gets more room)
 *   --demo-ratio  the video's own width / height, which sizes the screen without stretching or cropping it
 */
.gi { max-width: 1260px; }
.layout { --cab-max: 760px; --marquee-h: 190px; --screen-min: 440px;
	display: grid; grid-template-columns: minmax(0, var(--cab-max)) minmax(285px, 360px); gap: 28px; justify-content: center; align-items: start; }
.layout.is-portrait { --cab-max: 550px; --marquee-h: 140px; }
.layout > .cabinet { grid-column: 1; grid-row: 1; min-width: 0; }
.layout > .detail  { grid-column: 2; grid-row: 1; min-width: 0; align-self: start; }

/* ---- Cabinet ---------------------------------------------------------------------------------- */
.cabinet { width: 100%; filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .45)); }
.cab-marquee { height: var(--marquee-h); display: flex; align-items: center; justify-content: center; overflow: hidden; box-sizing: border-box;
	background: linear-gradient(#192943, #0d1828); border: 9px solid #26364a; border-bottom: 5px solid #05090f; transition: height .2s ease; }
.cab-marquee img { width: 100%; height: 100%; object-fit: contain; }          /* contain: never distorted or cropped */
.cab-marquee-name { font-family: var(--gc-font-arcade); font-size: clamp(14px, 3vw, 24px); color: var(--gc-yellow); text-align: center; padding: 0 12px; }

.cab-frame { padding: 18px 24px 20px; border-left: 12px solid #1a2430; border-right: 12px solid #1a2430;
	background: linear-gradient(115deg, #252b34, #48505b 12%, #252d38 27%, #343c45 80%, #171c24); }
.cab-screen { position: relative; overflow: hidden; border: 15px solid #030508; border-radius: 36px; background: #010408; box-shadow: inset 0 0 35px #000; }
.cab-screen::after { content: ''; pointer-events: none; position: absolute; inset: 0; opacity: .16;
	background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, .07) 4px); }
/* One screen box for every tab, sized by the video's ratio, so switching tabs never moves the page */
.cab-screenbody { display: flex; flex-direction: column; box-sizing: border-box; width: 100%; aspect-ratio: var(--demo-ratio);   /* a definite width, so min-height cannot widen the box through the ratio */
	min-height: var(--screen-min); max-height: min(70vh, 720px); }
.mode { flex: 1 1 auto; min-height: 0; overflow: auto; display: none; box-sizing: border-box; padding: 18px; }
.mode.active { display: flex; flex-direction: column; justify-content: center; }
.mode:focus-visible { outline-offset: -4px; }
#panel-demo { padding: 0; overflow: hidden; }
#panel-graphs { padding: 10px 12px; justify-content: flex-start; }

/* High scores */
.score-table { width: 100%; border-collapse: collapse; }
.score-table th { padding: 0 8px 9px; border-bottom: 1px solid #32475a; color: var(--gc-muted); font-size: 12px; font-weight: var(--gc-fw-heading); letter-spacing: 1px; text-align: left; }
.score-table td { padding: 8px; border-bottom: 1px solid #25364a; font-size: 18px; font-weight: var(--gc-fw-heading); }
.score-table .num { text-align: right; }
.score-table .rank, .score-table .who a { color: var(--gc-cyan); }
.score-table .who a:hover { color: var(--gc-yellow); border-bottom: 0; }
.score-table .score { color: var(--gc-yellow); font-variant-numeric: tabular-nums; }
.score-table .date { color: var(--gc-muted); font-size: 14px; font-weight: var(--gc-fw-strong); white-space: nowrap; }
.score-table .rank { width: 2.4rem; }
.score-table tr.first td { background: #162b2b; }
.score-table tr.first .score { color: var(--gc-green); }
.screen-empty { text-align: center; color: var(--gc-muted); }
.screen-empty .pixel { color: var(--gc-yellow); font-size: 14px; }

/* Demo video */
.demo { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; background: #000; }
.demo video { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; background: #000; }
.demo-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 11px 20px; background: rgba(0, 0, 0, .78);
	border: 1px solid var(--gc-cyan); border-radius: 4px; color: #fff; font: var(--gc-fs-label) var(--gc-font-arcade); cursor: pointer; }
.demo-play:hover { background: var(--gc-cyan); color: var(--gc-on-accent); }
.demo-status { position: absolute; inset: auto 8px 8px 8px; margin: 0; padding: 5px 8px; background: rgba(3, 7, 12, .86); color: var(--gc-muted); font-size: 14px; text-align: center; }
.demo.is-error video { visibility: hidden; }
.demo.is-error .demo-status { inset: 0; display: flex; align-items: center; justify-content: center; background: transparent; font-size: 18px; }

/* Tabs */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid #273e53; background: #03070c; }
.tab { padding: 12px 3px; border: 0; border-right: 1px solid #273e53; background: #050a12; color: var(--gc-muted); font: inherit; font-size: 15px; font-weight: var(--gc-fw-heading); letter-spacing: 1px; cursor: pointer; }
.tab:last-child { border-right: 0; }
.tab:hover { color: var(--gc-text); background: #0a1522; }
.tab.active { background: var(--gc-cyan); color: var(--gc-on-accent); }
.tab:focus-visible { outline-offset: -4px; }

/* Control panel: shown at its own proportions, never cropped */
.cab-controls { border: 10px solid #1d2734; border-top: 3px solid #030508; background: #111; line-height: 0; }
.cab-controls img { display: block; width: 100%; height: auto; }
.cab-controls-missing { display: block; padding: 22px 12px; line-height: 1.4; text-align: center; color: #8faabd; font: 8px/1.8 var(--gc-font-arcade);
	background: repeating-linear-gradient(135deg, #0c1625 0, #0c1625 8px, #111f31 8px, #111f31 10px); }

/* ---- Graphs ----------------------------------------------------------------------------------- */
.chart-panel { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chart-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.chart-title { font-size: 16px; color: var(--gc-text); }
.chart-ranges { display: flex; flex-wrap: wrap; gap: 6px; }
.chart-ranges button, .chart-close { padding: 5px 12px; border: 1px solid #34506a; background: var(--gc-panel); color: var(--gc-muted); font: inherit; font-size: 13px; font-weight: var(--gc-fw-strong); cursor: pointer; }
.chart-ranges button:hover, .chart-close:hover { color: var(--gc-text); border-color: var(--gc-cyan); }
.chart-ranges button[aria-pressed="true"] { background: var(--gc-cyan); color: var(--gc-on-accent); border-color: var(--gc-cyan); }
.chart-message { margin: 18px 0; text-align: center; color: var(--gc-muted); }
.chart-message[hidden], .chart-legend[hidden], .chart-plot[hidden], .chart-table[hidden] { display: none; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.chart-legend button { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px; border: 1px solid transparent; background: none; color: var(--gc-text); font: inherit; font-size: 15px; font-weight: var(--gc-fw-heading); cursor: pointer; }
.chart-legend button:hover { border-color: #34506a; }
.chart-legend button[aria-pressed="false"] { opacity: .4; text-decoration: line-through; }
.chart-legend small { color: var(--gc-muted); font-weight: var(--gc-fw-body); font-size: 13px; }
.chart-plot { position: relative; overflow-x: auto; }
.chart-plot svg { display: block; }
.chart-plot text { font-family: var(--gc-font-ui); fill: var(--gc-muted); font-size: 12px; }
.chart-plot .axis-title { font-size: 11px; letter-spacing: 1px; }
.chart-tip { position: absolute; z-index: 2; pointer-events: none; padding: 6px 9px; background: #03070cf0; border: 1px solid var(--gc-line-strong); border-radius: 3px; font-size: 14px; line-height: 1.3; white-space: nowrap; }
.chart-tip b { font-size: 16px; }
.chart-table summary { cursor: pointer; color: var(--gc-cyan); font-size: 13px; letter-spacing: 1px; }
.table-scroll { max-height: 200px; overflow: auto; margin-top: 6px; }
.table-scroll table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-scroll th, .table-scroll td { padding: 3px 6px; border-bottom: 1px solid #25364a; text-align: left; font-weight: var(--gc-fw-strong); }
.table-scroll td:last-child { text-align: right; }
.chart-expand { margin-left: 4px; color: var(--gc-cyan) !important; }

.chart-dialog { width: min(1100px, 96vw); max-height: 94vh; padding: 0; border: 1px solid var(--gc-line-strong); background: #060c16; color: var(--gc-text); box-shadow: 0 20px 60px #000; }
.chart-dialog::backdrop { background: rgba(0, 0, 0, .75); }
.chart-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--gc-line); }
.chart-dialog-head h2 { margin: 0; font-size: 12px; font-weight: var(--gc-fw-body); color: var(--gc-yellow); }
.chart-dialog-body { padding: 12px 16px 16px; overflow: auto; max-height: calc(94vh - 60px); }
.chart-dialog .chart-title, .chart-dialog .chart-expand { display: none; }

/* ---- Info panel ------------------------------------------------------------------------------- */
.detail { background: #0e1828; border: 1px solid var(--gc-line); border-radius: 5px; overflow: hidden; }
.detail-top { padding: 23px 24px 17px; border-bottom: 1px solid var(--gc-line); }
.detail .rom { color: var(--gc-muted); font-size: 12px; letter-spacing: 2px; }
.game-title { margin: 7px 0 4px; color: var(--gc-yellow); font-size: 33px; font-weight: var(--gc-fw-heading); line-height: 1.05; overflow-wrap: anywhere; }
.subtitle { font-size: 15px; color: var(--gc-cyan); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 0; padding: 20px 24px; border-bottom: 1px solid var(--gc-line); }
.fact dt { color: var(--gc-muted); font-size: 12px; font-weight: var(--gc-fw-strong); letter-spacing: 1px; }
.fact dd { margin: 2px 0 0; font-size: 19px; font-weight: var(--gc-fw-heading); }
.good { color: var(--gc-green); }
.bad { color: var(--gc-pink); }
.detail-section { padding: 20px 24px; border-bottom: 1px solid var(--gc-line); }
.detail-section h3 { margin: 0 0 16px; font: var(--gc-fs-label)/1.7 var(--gc-font-arcade); color: var(--gc-cyan); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat { padding: 12px 7px; border: 1px solid #2b4259; border-radius: 3px; background: #15243a; text-align: center; }
.stat strong { display: block; font-size: 23px; color: var(--gc-yellow); }
.stat span { font-size: 11px; color: var(--gc-muted); }
.note, .plays-total { margin: 0; color: var(--gc-muted); font-size: 15px; }
.plays-total strong { color: var(--gc-text); }
.activity { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 12px; }
.activity i { flex: 1; min-height: 3px; background: linear-gradient(var(--gc-cyan), #246a8c); opacity: .85; }
.activity i.none { background: #25364a; opacity: 1; }
.activity i:hover { opacity: 1; background: var(--gc-yellow); }
.activity-axis { display: flex; justify-content: space-between; margin-top: 4px; color: var(--gc-muted); font-size: 12px; }
.action { display: block; margin: 17px 24px 24px; padding: 10px; border: 1px solid #4b7889; border-radius: 3px; color: var(--gc-cyan); text-align: center; }
.action:hover { background: var(--gc-hover-bg); border-bottom: 1px solid #4b7889; color: var(--gc-yellow); }

/* ---- Tablet and phone: the info panel moves below the cabinet ------------------------------------ */
@media (max-width: 900px) {
	.layout { grid-template-columns: minmax(0, var(--cab-max)); }
	.layout > .cabinet { grid-column: 1; grid-row: 1; }
	.layout > .detail { grid-column: 1; grid-row: 2; max-width: 650px; width: 100%; margin: 0 auto; }
}
@media (max-width: 650px) {
	.layout { --marquee-h: 130px; --screen-min: 400px; gap: 14px; }
	.layout.is-portrait { --marquee-h: 105px; --cab-max: 100%; }
	.gi.content { padding-left: 8px; padding-right: 8px; }
	.cab-marquee { border-width: 6px; }
	.cab-frame { padding: 10px 9px; border-left-width: 7px; border-right-width: 7px; }
	.cab-screen { border-width: 8px; border-radius: 22px; }
	.mode { padding: 9px; }
	.score-table td { font-size: 15px; padding: 8px 3px; }
	.score-table th { padding-left: 3px; padding-right: 3px; }
	.score-table .date { font-size: 11px; }
	.cab-controls { border-width: 6px; border-top-width: 3px; }
	.detail-top, .facts, .detail-section { padding: 16px; }
	.game-title { font-size: 28px; }
	.stats { gap: 4px; }
	.stat strong { font-size: 20px; }
	.action { margin-left: 16px; margin-right: 16px; }
	.chart-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; }
	.chart-dialog-body { max-height: calc(100dvh - 60px); }
}
@media (prefers-reduced-motion: reduce) { .cab-marquee { transition: none; } }
