/* Colors follow the original title menu: orange, coral, turquoise and lime. */
:root {
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff5e5;
  line-height: 1.5;
  font-synthesis: none;
  --ink: #49332c;
  --muted: #72564a;
  --line: #e8ba91;
  --coral: #e94e72;
  --turquoise: #087c9e;
  --lime: #d7e475;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 12% 0, #ffc17b 0, transparent 48%),
    radial-gradient(ellipse at 98% 12%, #f6afad 0, transparent 46%), #fff5e5;
}
button, a, input { font: inherit; }
a { color: #086c8b; }
button, .file-button {
  border: 1px solid #d8b593;
  border-radius: 12px;
  background: #fffdf0;
  color: var(--ink);
  padding: .65rem .9rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 0 #e5c4a6;
  transition: background .12s, transform .12s;
}
button:hover:not(:disabled), .file-button:hover { background: #f3f6ce; }
button:active:not(:disabled), button.is-held {
  transform: translateY(2px);
  box-shadow: none;
  background: #dce992;
}
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, .file-button:focus-within,
canvas:focus-visible, input:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 4px; }
[hidden] { display: none !important; }
.shell { width: min(100% - 32px, 800px); margin: auto; padding: 28px 0 max(24px, env(safe-area-inset-bottom)); }
.masthead { text-align: center; margin: 0 0 24px; }
h1 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -.055em;
  font-size: clamp(2.7rem, 8vw, 4.5rem);
  line-height: 1.1;
  margin: 0;
  font-weight: 500;
  color: #fffef0;
  text-shadow: -1px -1px 0 #7c8826, 1px -1px 0 #7c8826,
    -1px 1px 0 #7c8826, 1px 1px 0 #7c8826, 0 4px 0 #e86c76;
}
h1 span { font-size: .55em; vertical-align: top; margin-left: 9px; color: #e94e72; text-shadow: none; }
.description { font-size: .87rem; color: var(--ink); max-width: 570px; margin: 17px auto 0; }
.console {
  padding: 24px;
  border: 1px solid #e9b68c;
  border-radius: 28px;
  background: #fff9eb;
  box-shadow: 0 12px 36px #9f5b2612, 0 2px 0 #fff inset;
}
.screen-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  border: 7px solid #ed8a95;
  border-radius: 11px;
  overflow: hidden;
  background: #171019;
  box-shadow: 0 0 0 1px #cd6479, 0 2px 7px #75324633 inset;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 1px;
  min-height: 1px;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #171019;
  image-rendering: pixelated;
  touch-action: none;
}
.screen-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  color: #fffef0;
  text-align: center;
  background: #117c9d;
}
.cover-star { font-size: 3.5rem; color: var(--lime); line-height: 1; }
.screen-cover p { margin: 12px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.2rem, 4vw, 2rem); }
.screen-cover .cover-detail { font-family: inherit; font-size: .8rem; max-width: 310px; color: #fffef0; }
.player-toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin: 20px 0; }
.player-toolbar button { font-size: .8rem; min-height: 44px; }
.primary { background: var(--turquoise); color: #fff; border-color: #086683; box-shadow: 0 2px 0 #07536b; }
.primary:hover:not(:disabled) { background: #086a88; }
.player-status { text-align: center; font-size: .76rem; color: var(--muted); margin: -8px 0 19px; }
.player-status.error, #save-status.error { color: #ac2341; }
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.controls button { touch-action: none; min-width: 44px; min-height: 44px; padding: .55rem .6rem; }
.dpad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 3px; flex: none; }
.dpad button { font-size: 1.15rem; padding: 0; background: #eff3c8; border-color: #c4ca81; box-shadow: 0 2px 0 #cbd38a; }
.up { grid-column: 2; grid-row: 1; }
.left { grid-column: 1; grid-row: 2; }
.right { grid-column: 3; grid-row: 2; }
.down { grid-column: 2; grid-row: 3; }
.dpad-center { grid-column: 2; grid-row: 2; display: grid; place-items: center; font-size: 1.35rem; color: #84942a; }
.action-buttons { display: grid; grid-template-columns: repeat(3, minmax(44px, 66px)); gap: 9px; }
.action-buttons .select-button { grid-column: 1/-1; background: #d1eef3; border-color: #89c5d2; box-shadow: 0 2px 0 #a9d4de; }
.action-buttons button { font-size: .82rem; }
.action-buttons small { display: inline-block; color: var(--muted); font-weight: 450; font-size: .65rem; margin-left: 4px; }
.control-help { text-align: center; font-size: .75rem; color: var(--muted); margin: 20px auto 0; max-width: 460px; }
.save-panel { border: 1px solid var(--line); border-radius: 20px; background: #fffbee; padding: 20px 22px; margin: 20px 0; }
.save-panel h2 { font-size: 1rem; font-weight: 650; margin: 0 0 6px; }
.save-panel #save-status { font-size: .8rem; color: var(--muted); margin: 0; }
.save-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 15px 0; }
.save-tools button, .file-button { font-size: .8rem; padding: .55rem .75rem; min-height: 44px; }
.file-button { display: inline-block; }
.file-button:has(+input:disabled) { opacity: .5; cursor: default; }
#import-save { max-width: 100%; font-size: .75rem; color: var(--muted); }
#import-save::file-selector-button { display: none; }
.save-notice { font-size: .77rem; color: var(--muted); margin: 10px 0 0; }
footer { text-align: center; padding: 5px 13px 0; font-size: .69rem; color: var(--muted); }
footer p { margin: 7px 0; }
.screen-frame.crt canvas { image-rendering: auto; }
.screen-frame.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, #00000024 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at center, transparent 52%, #120b243d 100%);
  border-radius: 3px;
  box-shadow: inset 0 0 18px #11092145;
}
.screen-frame.crt .screen-cover { z-index: 1; }
#crt-filter { min-width: 44px; min-height: 44px; }
@media (max-width: 520px) {
  .shell { width: min(100% - 20px, 800px); padding-top: 18px; }
  .masthead { margin-bottom: 19px; }
  .description { font-size: .8rem; margin-top: 13px; }
  .console { padding: 12px; border-radius: 23px; }
  .screen-frame { border-width: 5px; }
  .player-toolbar { gap: 7px; margin: 15px 0 17px; }
  .player-toolbar button { font-size: .72rem; padding: .55rem .7rem; }
  .player-status { margin: -7px 3px 17px; font-size: .72rem; }
  .controls { gap: 23px; }
  .action-buttons { grid-template-columns: repeat(3, minmax(44px, 58px)); gap: 7px; }
  .action-buttons button { font-size: .76rem; }
  .action-buttons small { font-size: .58rem; margin-left: 2px; }
  .control-help { font-size: .72rem; margin-top: 17px; }
  .save-panel { padding: 17px; margin-top: 15px; }
  .save-tools { gap: 8px; }
}
@media (max-width: 350px) {
  .controls { gap: 12px; }
  .action-buttons { grid-template-columns: repeat(2, 44px); gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (min-width: 600px) and (orientation: landscape) and (max-height: 600px) {
  .shell { width: min(100% - 20px, 1000px); padding-top: 6px; }
  .masthead { display: flex; align-items: center; gap: 18px; margin: 0 0 9px; }
  h1 { font-size: 1.9rem; flex-shrink: 0; }
  .description { text-align: left; font-size: .7rem; margin: 0; max-width: 500px; }
  .console {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 295px;
    grid-template-areas: "stage controls" "toolbar controls" "status help";
    gap: 5px 12px;
    padding: 10px;
    border-radius: 16px;
  }
  .screen-frame { grid-area: stage; width: min(100%, max(160px, calc((100dvh - 132px)*4/3))); justify-self: center; border-width: 4px; }
  .controls { grid-area: controls; gap: 13px; }
  .action-buttons { grid-template-columns: repeat(3, 44px); gap: 6px; }
  .action-buttons small { display: none; }
  .player-toolbar { grid-area: toolbar; margin: 3px 0 0; gap: 6px; }
  .player-toolbar button { min-height: 44px; font-size: .66rem; padding: .35rem .55rem; }
  .player-status { grid-area: status; font-size: .65rem; margin: 0; }
  .control-help { grid-area: help; font-size: .65rem; margin: 0; }
  .save-panel { margin-top: 12px; }
}
