:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: #e5edf6;
  background: #07101a;
  font-synthesis: none;
  --surface: #0e1a28;
  --surface-raised: #142333;
  --border: #243549;
  --muted: #8ca0b6;
  --accent: #35e1df;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; border: 1px solid var(--border); background: var(--surface-raised); border-radius: 8px; }
button:disabled { cursor: default; opacity: .38; }
button:not(:disabled):hover { background: #20344a; border-color: #3a536a; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.site-header { display: flex; align-items: center; justify-content: space-between; height: 70px; padding: 0 28px; border-bottom: 1px solid #1b2a3a; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 750; letter-spacing: -.7px; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid #24535e; border-radius: 9px; background: #10323d; color: var(--accent); font: 800 23px var(--mono); }
.site-nav { display: flex; gap: 22px; font-size: 11px; color: var(--muted); }
.site-nav span { margin-left: 3px; }
main { padding: 22px 28px; max-width: 1680px; margin: auto; }
.workspace { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; min-height: calc(100dvh - 114px); }
.sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.library-panel { overflow: hidden; flex: 1 1 auto; min-height: 240px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px 12px; }
h2 { margin: 0; font-size: 13px; font-weight: 650; }
.count { margin-left: 5px; color: #8299af; font: 11px var(--mono); }
.add-game { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; min-height: 30px; color: #8cf3ef; border-color: #24515d; background: #123540; font-size: 11px; }
.add-game > span { font-size: 16px; line-height: 1; }
.game-list { display: flex; flex-direction: column; gap: 5px; padding: 0 8px 8px; max-height: max(240px, calc(100dvh - 390px)); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #34475c transparent; }
.game-list:empty { padding: 0; }
.game-item { display: flex; align-items: center; min-width: 0; border: 1px solid transparent; border-radius: 8px; }
.game-item.selected { background: #112f3d; border-color: #236174; }
.game-select { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 11px 4px 11px 9px; background: transparent; border: 0; text-align: left; }
.game-select:not(:disabled):hover { background: #183243; }
.game-icon { flex-shrink: 0; display: grid; place-items: center; width: 34px; height: 40px; border: 1px solid #304659; border-radius: 6px; background: #213144; font: 700 17px var(--mono); color: #b7c9dc; }
.selected .game-icon { background: #194856; border-color: #2f6874; color: #83e8e4; }
.game-copy { min-width: 0; }
.game-name { display: block; font-size: 12px; font-weight: 600; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-detail { display: block; margin-top: 5px; font: 9px var(--mono); color: var(--muted); }
.remove-game { flex-shrink: 0; width: 27px; height: 30px; padding: 0; margin-right: 4px; border: 0; background: transparent; color: #7d97ad; font-size: 18px; }
.remove-game:not(:disabled):hover { background: #402936; color: #ffc3cb; }
.library-empty { min-height: 180px; padding: 36px 14px; text-align: center; color: #61788f; }
.library-empty svg { display: block; margin: 0 auto 15px; }
.library-empty p { font-size: 12px; margin: 0 0 8px; color: var(--muted); }
.library-empty > span { font: 10px var(--mono); }
.options-group { display: flex; flex-direction: column; gap: 8px; }
.option-panel { overflow: hidden; }
.option-panel summary { display: flex; align-items: center; justify-content: space-between; min-height: 46px; padding: 12px 16px; list-style: none; cursor: pointer; font-size: 12px; font-weight: 550; color: #b8c8d8; }
.option-panel summary::-webkit-details-marker { display: none; }
.option-panel summary:hover { background: #132434; }
.chevron { color: #6b859d; font-size: 15px; }
.option-panel[open] .chevron { transform: rotate(180deg); }
.option-content, .settings { padding: 2px 16px 16px; }
.settings { display: grid; gap: 15px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 9px; font-size: 11px; color: var(--muted); }
.setting-row select { max-width: 125px; border: 1px solid #2a4055; border-radius: 6px; padding: 6px 7px; color: #d5e1ef; background: #142535; font-size: 11px; }
.volume-row button { border: 0; padding: 4px 0; background: transparent; font-size: 11px; color: var(--muted); white-space: nowrap; }
.volume-row button > span { margin-left: 5px; color: #b1c7d8; font: 10px var(--mono); }
.volume-row input { width: 108px; min-width: 0; height: 18px; margin: 0; accent-color: #34ccc9; cursor: pointer; }
.save-actions { display: flex; gap: 7px; }
.save-actions button { flex: 1; min-height: 34px; padding: 7px; font-size: 11px; }
.save-actions span { color: #8fa5bb; margin-left: 4px; }
.save-status { display: block; margin-top: 12px; font-size: 10px; line-height: 1.65; color: #a2b6cb; overflow-wrap: anywhere; }
.save-status.error { color: #ffa1a5; }
.storage-note { margin: 8px 0 0; font-size: 10px; line-height: 1.65; color: #718ba4; }
.key-guide-row { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin: 9px 0; font-size: 10px; color: var(--muted); }
.key-guide-row > span:last-child { display: flex; gap: 4px; }
kbd { display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px; background: #162638; border: 1px solid #30445a; border-bottom-width: 2px; border-radius: 4px; color: #b1c6d9; font: 9px var(--mono); }
.local-note { display: flex; align-items: center; gap: 6px; margin: 5px 4px 0; color: #637d94; font-size: 9px; line-height: 1.6; }
.local-note span { color: #477b81; font-size: 9px; }
.play-area { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.player-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 19px 24px; border-bottom: 1px solid #223347; }
.now-playing { min-width: 0; }
.now-playing h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.35px; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-playing p { margin: 5px 0 0; font-size: 10px; color: #7f98b0; font-family: var(--mono); }
.session-controls { display: flex; gap: 7px; flex-shrink: 0; }
.session-controls button { min-height: 36px; padding: 9px 12px; white-space: nowrap; font-size: 11px; }
.session-controls .primary-button { background: #2dd7d3; color: #05282d; border-color: #2dd7d3; font-weight: 750; }
.session-controls .primary-button:not(:disabled):hover { background: #72efeb; border-color: #72efeb; }
.primary-button span { font-size: 9px; margin-right: 3px; }
.device-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 43px; padding: 10px 24px; color: #708ba3; font: 9px var(--mono); }
.live-label { display: flex; align-items: center; gap: 6px; }
.live-label i { width: 5px; height: 5px; border-radius: 50%; background: #596b7c; }
.live-label i.active { background: #35d7bd; box-shadow: 0 0 6px #35d7bd50; }
.screen-info { display: flex; align-items: center; gap: 15px; }
#fps { min-width: 43px; text-align: right; color: #a4c2d6; }
.player-stage { --screen-height: clamp(300px, calc(100dvh - 285px), 720px); display: grid; grid-template-columns: minmax(0,1fr) 242px; align-items: center; flex: 1; gap: 28px; padding: 10px 30px 30px; }
.display-area { display: flex; justify-content: center; align-items: center; min-width: 0; width: 100%; }
.screen-wrap { --screen-ratio: .75; position: relative; width: min(100%, calc(var(--screen-height) * var(--screen-ratio))); aspect-ratio: 3 / 4; background: #03070c; overflow: hidden; box-shadow: 0 0 0 1px #21364b, 0 16px 50px -22px #000; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: pan-y; }
.screen-wrap.touch canvas { touch-action: none; }
.screen-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 17px; background: #080f19; color: #3d6078; }
.screen-placeholder p { margin: 0; padding: 0 15px; text-align: center; color: #637f99; font-size: 11px; line-height: 1.65; }
.pause-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; color: #e7f1fb; background: #08111bcc; }
.pause-overlay > span { font-size: 35px; font-weight: 300; }
.pause-overlay strong { font-size: 12px; font-weight: 500; }
.keypad { align-self: center; display: flex; flex-direction: column; gap: 18px; padding: 19px 14px; border: 1px solid #27394c; border-radius: 12px; background: #101e2c; user-select: none; -webkit-user-select: none; }
.keypad button { padding: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; border-color: #2c4155; background: #192c3d; box-shadow: 0 2px 0 #060d16; }
.keypad button:disabled { opacity: .45; }
.keypad button.pressed, .keypad button:not(:disabled):active { background: #37d5d0; color: #062e33; border-color: #5df4e9; box-shadow: inset 0 1px 3px #0e66664d; }
.navigation-keys { display: grid; grid-template-columns: 45px 104px 45px; justify-content: center; align-items: center; gap: 9px; }
.soft-keys { display: flex; flex-direction: column; gap: 17px; }
.soft-keys button { width: 45px; height: 36px; border-radius: 6px; color: #a4bbcf; font: 8px var(--mono); letter-spacing: .25px; }
.soft-keys button.call-key { color: #83cdb5; }
.soft-keys button.clear-key { color: #c3acd5; }
.dpad { display: grid; width: 104px; height: 120px; grid-template-columns: 32px 40px 32px; grid-template-rows: 38px 44px 38px; }
.dpad button { color: #8aacc6; font-size: 19px; border-radius: 7px; }
.dpad .up { grid-column: 2; grid-row: 1; border-radius: 7px 7px 2px 2px; }
.dpad .left { grid-column: 1; grid-row: 2; border-radius: 7px 2px 2px 7px; }
.dpad .ok { grid-column: 2; grid-row: 2; background: #23475a; color: #92e6eb; font: 600 10px var(--mono); border-color: #326275; border-radius: 5px; z-index: 1; }
.dpad .right { grid-column: 3; grid-row: 2; border-radius: 2px 7px 7px 2px; }
.dpad .down { grid-column: 2; grid-row: 3; border-radius: 2px 2px 7px 7px; }
.number-keys { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.number-keys button { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; height: 45px; border-radius: 7px; color: #c2d3e2; font: 18px var(--mono); }
.number-keys small { color: #718da5; font: 6px var(--mono); }
.number-keys button.pressed small { color: #14565c; }
.notice { display: flex; align-items: center; gap: 8px; min-height: 41px; margin-top: auto; padding: 11px 24px; border-top: 1px solid #203146; color: #768fa8; font-size: 10px; line-height: 1.65; overflow-wrap: anywhere; }
.notice-dot { width: 4px; height: 4px; flex-shrink: 0; border-radius: 50%; background: #467b83; }
.notice.error { color: #ffacb0; background: #301b2770; }
.notice.error .notice-dot { background: #f78796; }
.drop-overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: #07101aeb; color: #d5f7f7; pointer-events: none; }
.drop-overlay > div { width: min(440px,100%); height: 280px; border: 1px dashed #35d6d2; border-radius: 16px; background: #133140; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.drop-overlay span { margin-bottom: 20px; color: var(--accent); font-size: 40px; font-weight: 300; }
.drop-overlay strong { font-size: 19px; font-weight: 550; }
.drop-overlay p { color: #83aebf; font: 12px var(--mono); }
.noscript { padding: 20px; background: #402333; text-align: center; }
@media (min-width: 1500px) { .workspace { grid-template-columns: 280px minmax(0,1fr); gap: 24px; } .player-stage { grid-template-columns: minmax(0,1fr) 260px; padding-inline: 50px; gap: 40px; } .keypad { padding: 24px 20px; } }
@media (max-width: 1150px) { main { padding: 18px; } .site-header { padding-inline: 20px; } .workspace { grid-template-columns: 230px minmax(0,1fr); gap: 14px; min-height: calc(100dvh - 106px); } .player-stage { grid-template-columns: minmax(0,1fr) 212px; gap: 18px; padding: 8px 18px 24px; } .keypad { padding: 14px 9px; } .navigation-keys { grid-template-columns: 38px 100px 38px; gap: 6px; } .soft-keys button { width: 38px; font-size: 7px; } .dpad { width: 100px; grid-template-columns: 30px 40px 30px; } .number-keys { gap: 7px; } .number-keys small { display: none; } .player-toolbar { padding: 16px 18px; gap: 10px; } .session-controls { gap: 5px; } .session-controls button { padding-inline: 9px; font-size: 10px; } .device-topline, .notice { padding-inline: 18px; } }
@media (max-width: 950px) and (min-width: 721px) { .workspace { grid-template-columns: 210px minmax(0,1fr); } .player-toolbar { flex-wrap: wrap; } .session-controls { width: 100%; } .session-controls button { flex: 1; } .player-stage { --screen-height: 400px; grid-template-columns: minmax(0,1fr); gap: 22px; } .keypad { width: 100%; max-width: 390px; justify-self: center; flex-direction: row; align-items: center; gap: 17px; } .navigation-keys { grid-template-columns: 38px 100px 38px; } .number-keys { flex: 1; min-width: 100px; gap: 6px; } .number-keys button { height: 33px; font-size: 14px; } }
@media (max-width: 720px), (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  .site-header { height: 54px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
  .brand { font-size: 18px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; font-size: 20px; border-radius: 8px; }
  .site-nav { gap: 14px; font-size: 10px; }
  main { padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .workspace { display: flex; flex-direction: column; min-height: 0; gap: 12px; }
  .sidebar { display: contents; }
  .library-panel { order: 1; flex: none; min-height: 0; }
  .panel-heading { padding: 9px 12px; }
  .panel-heading h2 { font-size: 12px; }
  .add-game { min-height: 29px; padding: 5px 9px; }
  .game-list { flex-direction: row; gap: 6px; max-height: none; padding: 0 7px 7px; overflow-x: auto; overflow-y: hidden; }
  .game-item { flex: 0 0 auto; max-width: 290px; min-width: 190px; }
  .game-select { padding: 7px 4px 7px 8px; gap: 8px; }
  .game-icon { width: 27px; height: 32px; font-size: 14px; }
  .game-detail { font-size: 8px; margin-top: 3px; }
  .game-name { font-size: 11px; }
  .game-list:empty { padding: 0; }
  .library-empty { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 0; padding: 5px 12px 15px; }
  .library-empty svg { display: none; }
  .library-empty p { font-size: 11px; margin: 0; }
  .library-empty > span { font-size: 9px; }
  .options-group { order: 3; gap: 7px; }
  .option-panel summary { min-height: 44px; }
  .option-content, .settings { padding-bottom: 16px; }
  .settings { max-width: 440px; }
  .save-actions { max-width: 380px; }
  .save-actions button { min-height: 38px; }
  .key-guide-row { max-width: 380px; min-height: 22px; }
  .local-note { margin: 5px 3px 0; font-size: 10px; }
  .play-area { order: 2; }
  .player-toolbar { padding: 12px; flex-wrap: wrap; gap: 11px; }
  .now-playing { flex: 1 1 auto; }
  .now-playing h1 { font-size: 14px; }
  .now-playing p { display: none; }
  .session-controls { gap: 5px; width: auto; }
  .session-controls button { min-height: 34px; padding: 8px 10px; font-size: 10px; }
  .device-topline { min-height: 31px; padding: 8px 12px; font-size: 8px; }
  .screen-info { gap: 11px; }
  .player-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 7px 12px 13px; }
  .display-area { width: 100%; }
  .screen-wrap { width: 100%; max-width: none; }
  .keypad { display: grid; grid-template-columns: 132px minmax(0,1fr); gap: 14px; align-items: center; width: min(100%, 440px); padding: 10px; border-radius: 9px; }
  .navigation-keys { grid-template-columns: repeat(2, 1fr); gap: 5px; }
  .soft-keys { display: contents; }
  .soft-keys button { width: 100%; height: 36px; font-size: 8px; }
  .soft-keys:first-child button:first-child { grid-column: 1; grid-row: 1; }
  .soft-keys:last-child button:first-child { grid-column: 2; grid-row: 1; }
  .soft-keys:first-child button:last-child { grid-column: 1; grid-row: 3; }
  .soft-keys:last-child button:last-child { grid-column: 2; grid-row: 3; }
  .dpad { grid-column: 1 / -1; grid-row: 2; width: 132px; height: 132px; grid-template-columns: repeat(3,44px); grid-template-rows: repeat(3,44px); }
  .dpad .direction { font-size: 17px; }
  .number-keys { gap: 6px; }
  .number-keys button { height: 48px; font-size: 18px; }
  .number-keys small { display: none; }
  .notice { min-height: 34px; padding: 8px 12px; font-size: 9px; }
  .session-active .library-panel .panel-heading { padding-block: 7px; }
  .session-active .library-panel .game-list { display: none; }
}
@media (max-width: 390px) {
  .site-nav { gap: 11px; font-size: 9px; }
  .session-controls { width: 100%; }
  .session-controls button { flex: 1; }
  .player-toolbar { gap: 9px; }
  .keypad { grid-template-columns: 132px minmax(0,1fr); gap: 10px; padding: 8px; }
  .number-keys { gap: 5px; }
  .number-keys button { font-size: 14px; }
}
@media (max-width: 350px) {
  .keypad { display: flex; flex-direction: column; gap: 14px; }
  .navigation-keys { width: 100%; grid-template-columns: minmax(44px,1fr) 132px minmax(44px,1fr); gap: 5px; }
  .soft-keys { display: flex; flex-direction: column; gap: 22px; }
  .soft-keys button { height: 44px; }
  .dpad { grid-column: auto; grid-row: auto; }
  .number-keys { width: 100%; }
}
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  .session-active .site-header { display: none; }
  .session-active main { padding-top: 6px; }
  .session-active .library-panel { display: none; }
  .session-active .player-toolbar { flex-wrap: nowrap; padding: 6px 12px; }
  .session-active .session-controls { width: auto; }
  .session-active .session-controls button { min-height: 30px; padding: 6px 8px; }
  .session-active .device-topline { min-height: 22px; padding: 4px 12px; }
  .session-active .screen-wrap { width: min(100%, calc(var(--screen-height) * var(--screen-ratio))); }
  .session-active .player-stage { --screen-height: max(180px, calc(100svh - 92px)); display: grid; grid-template-columns: minmax(120px,1fr) minmax(290px,1fr); gap: 15px; padding: 4px 12px 10px; }
  .session-active .keypad { grid-template-columns: 132px minmax(0,1fr); gap: 8px; padding: 8px; }
}

/* The cheat controls share the sidebar and move below the player on phones. */
#cheat-panel { display: grid; gap: 12px; min-width: 0; }
#cheat-panel .cheat-row { display: flex; flex-wrap: wrap; align-items: end; gap: 7px; min-width: 0; }
#cheat-panel .cheat-field { display: grid; flex: 1 1 75px; gap: 6px; min-width: 0; color: #9eb4c8; font-size: 10px; }
#cheat-panel label { color: #9eb4c8; font-size: 10px; line-height: 1.5; }
#cheat-panel input:not([type="checkbox"]):not([type="file"]), #cheat-panel select { width: 100%; min-width: 0; min-height: 34px; padding: 7px 8px; border: 1px solid #2d4358; border-radius: 6px; color: #e0eaf5; background: #081522; font: 11px var(--mono); }
#cheat-panel input::placeholder { color: #627f98; }
#cheat-panel input:disabled, #cheat-panel select:disabled { opacity: .5; }
#cheat-panel input[type="checkbox"] { margin: 0 5px 0 0; accent-color: var(--accent); }
#cheat-panel .cheat-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#cheat-panel button { min-height: 32px; padding: 7px 9px; font-size: 10px; line-height: 1.35; white-space: nowrap; }
#cheat-panel .cheat-actions > button { flex: 1 1 auto; }
#cheat-panel .cheat-primary { border-color: #28636b; background: #17444d; color: #8ef4ed; }
#cheat-panel .cheat-primary:not(:disabled):hover { border-color: #3b8a8b; background: #205b63; }
#cheat-panel .cheat-danger { color: #d9afbf; }
#cheat-panel .cheat-state, #cheat-panel .cheat-help, #cheat-panel .cheat-watch, #cheat-panel .cheat-status { margin: 0; color: #7f9ab2; font-size: 10px; line-height: 1.7; overflow-wrap: anywhere; }
#cheat-panel .cheat-status { color: #a6c2d9; }
#cheat-panel .cheat-status.error { color: #ffacb0; }
#cheat-panel .cheat-results, #cheat-panel .cheat-frozen { display: flex; flex-direction: column; gap: 6px; max-height: 260px; min-width: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #365169 transparent; }
#cheat-panel .cheat-result, #cheat-panel .cheat-freeze { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; padding: 8px; border: 1px solid #263e51; border-radius: 7px; background: #0b1724; }
#cheat-panel .cheat-result > span, #cheat-panel .cheat-freeze > span { min-width: 0; color: #a7c0d4; font: 11px/1.6 var(--mono); overflow-wrap: anywhere; }
#cheat-panel .cheat-result > span:first-child, #cheat-panel .cheat-freeze > span:first-child { flex: 1 1 100%; }
#cheat-panel .cheat-value { flex: 1 1 60px; width: 60px; }
#cheat-panel .cheat-result > button, #cheat-panel .cheat-freeze > button { margin-left: auto; }
#cheat-panel .cheat-section-title { margin: 3px 0 0; color: #bdcfdf; font-size: 11px; font-weight: 600; }
#cheat-panel .cheat-divider { border: 0; border-top: 1px solid #24374b; margin: 0; width: 100%; }
#cheat-panel .cheat-state:empty, #cheat-panel .cheat-status:empty { display: none; }
#cheat-panel .cheat-state { padding: 8px 9px; border-radius: 6px; background: #142737; color: #a9cbdc; }
#cheat-panel .cheat-form { display: grid; gap: 10px; min-width: 0; padding: 0; margin: 0; border: 0; }
#cheat-panel .cheat-form:disabled { opacity: .6; }
#cheat-panel .cheat-row > label { flex: 1 1 75px; min-width: 0; }
#cheat-panel .cheat-row > label:has(input[type="checkbox"]) { display: flex; align-items: center; min-height: 34px; }
#cheat-panel .cheat-result code, #cheat-panel .cheat-freeze code { flex: 1 1 100%; color: #a4d6e1; font: 11px/1.55 var(--mono); overflow-wrap: anywhere; }
#cheat-panel .cheat-result-value { flex: 1 1 60px; color: #d4e9f4; font: 11px/1.55 var(--mono); }
#cheat-panel .cheat-freeze > label { flex: 1 1 100%; min-width: 0; }
#cheat-panel .cheat-freeze input.cheat-value { flex: 1 1 100%; width: 100%; font-size: 11px; }
#cheat-panel .cheat-freeze > button { flex: 1 1 auto; margin: 0; }
#cheat-panel .cheat-pager { display: flex; justify-content: space-between; align-items: center; gap: 6px; color: #8faec5; font: 10px var(--mono); }
#cheat-panel .cheat-pager button { flex: 0 0 auto; }
#cheat-panel .cheat-help { border-top: 1px solid #263c50; padding-top: 4px; }
#cheat-panel .cheat-help summary { min-height: 32px; padding: 6px 0; font-size: 10px; font-weight: 400; color: #8dabc3; }
#cheat-panel .cheat-help summary:hover { background: transparent; color: #b0dce5; }
#cheat-panel .cheat-help p { margin: 5px 0; }
#cheat-panel .cheat-help ol, #cheat-panel .cheat-help ul { margin: 5px 0; padding-left: 17px; }
#cheat-panel .cheat-count { margin: 1px 0 0; color: #a4bfd4; font: 11px/1.5 var(--mono); }
#cheat-panel .cheat-hint { margin: 0; color: #7895ad; font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
#cheat-panel .cheat-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; margin-top: 5px; padding-top: 12px; border-top: 1px solid #263c50; }
#cheat-panel .cheat-heading h3 { margin: 0; color: #bdcfdf; font-size: 11px; font-weight: 600; }
#cheat-panel .cheat-heading button { min-height: 28px; padding: 5px 7px; }
#cheat-panel .cheat-freeze-title { flex: 1 1 100%; min-width: 0; color: #d4e5f1; font-size: 11px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
#cheat-panel .cheat-freeze > .cheat-row { flex: 1 1 100%; width: 100%; }
#cheat-panel .cheat-freeze .cheat-row > button { flex: 1 1 auto; }
#cheat-panel .cheat-freeze .cheat-row > input.cheat-value { flex: 1 1 100%; width: 100%; }
#cheat-panel .cheat-row > select, #cheat-panel .cheat-row > input:not([type="checkbox"]) { flex: 1 1 100px; width: 0; }
#cheat-panel .cheat-row > .cheat-check { flex: 0 0 auto; min-width: 45px; align-self: end; color: #b8cfdf; }
#cheat-panel .cheat-direct, #cheat-panel .cheat-watch { min-width: 0; border-top: 1px solid #263c50; padding-top: 3px; }
#cheat-panel .cheat-direct > summary, #cheat-panel .cheat-watch > summary { min-height: 34px; padding: 7px 0; color: #9db8ce; font-size: 10px; font-weight: 500; }
#cheat-panel .cheat-direct > summary:hover, #cheat-panel .cheat-watch > summary:hover { color: #b0dce5; background: transparent; }
#cheat-panel .cheat-direct > :not(summary), #cheat-panel .cheat-watch > :not(summary) { margin-top: 10px; }
#cheat-panel .cheat-hits { display: grid; gap: 5px; max-height: 170px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #365169 transparent; }
#cheat-panel .cheat-hit { display: block; min-width: 0; padding: 6px 7px; color: #9fc4d6; background: #0a1622; border-radius: 5px; font: 11px/1.55 var(--mono); overflow-wrap: anywhere; }
#cheat-panel .cheat-table-actions { margin-top: 3px; padding-top: 13px; border-top: 1px solid #263c50; }


@media (max-width: 720px), (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  #cheat-panel { gap: 14px; }
  #cheat-panel .cheat-row { gap: 9px; }
  #cheat-panel .cheat-field { flex-basis: 100px; }
  #cheat-panel input:not([type="checkbox"]):not([type="file"]), #cheat-panel select { min-height: 40px; font-size: 16px; }
  #cheat-panel button { min-height: 38px; padding: 9px 11px; font-size: 11px; }
  #cheat-panel .cheat-results, #cheat-panel .cheat-frozen { max-height: 320px; }
  #cheat-panel .cheat-result, #cheat-panel .cheat-freeze { padding: 10px; }
}

/* Keep the game in view while the expanded desktop cheat sidebar scrolls. */
@media (min-width: 721px) and (min-height: 601px), (min-width: 1101px) {
  .workspace:has(#cheats[open]) { align-items: start; }
  .workspace:has(#cheats[open]) > .play-area { position: sticky; top: 18px; min-height: calc(100dvh - 114px); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
