:root {
  color-scheme: light;
  --paper: #f7f4e8;
  --ink: #253c37;
  --muted: #62736a;
  --mint: #afdcca;
  --mint-dark: #77bc9f;
  --line: #d8ddcd;
  --coral: #efb29c;
  --yellow: #f0d47f;
  --blue: #b7dbe3;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: ui-rounded, "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #2b8065; outline-offset: 4px; }
.games-shell { width: min(1240px, 100%); margin: 0 auto; padding: 0 24px; }
.games-header { display: flex; align-items: center; gap: 13px; min-height: 92px; padding: 18px 0; }
.page-heading { min-width: 0; flex: 1; }
h1 { margin: 0; font-size: 34px; font-weight: 850; letter-spacing: -.055em; line-height: 1.08; overflow-wrap: anywhere; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.header-actions { display: flex; gap: 9px; align-items: center; flex-shrink: 0; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1.5px solid var(--ink); border-radius: 12px; padding: 11px 19px; font-weight: 750; font-size: 15px; line-height: 1.2; text-decoration: none; background: #fffdf4; transition: transform .12s, background .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); background: #fff; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button-primary { background: var(--mint); box-shadow: 0 3px 0 var(--ink); }
.button-primary:hover:not(:disabled) { background: #c6e9d9; }
.button-primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--ink); }
.button-primary > span { font-size: 21px; line-height: 15px; font-weight: 500; }
.button-quiet { background: transparent; border-color: var(--line); }
.button-small { padding: 7px 12px; font-size: 13px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; text-decoration: none; flex-shrink: 0; }
.icon-button:hover { background: #e8ebdf; }
.back-link { margin-left: -7px; }
.text-button { border: 0; padding: 5px 0; font-size: 13px; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: #1b7557; }
.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.game-tile { min-width: 0; display: block; text-decoration: none; border-radius: 17px; overflow: hidden; border: 1.5px solid var(--ink); background: #fffdf5; box-shadow: 0 3px 0 #253c3726; transition: transform .15s, box-shadow .15s; }
.game-tile:hover { transform: translateY(-3px); box-shadow: 0 6px 0 #253c3726; }
.tile-art { display: flex; position: relative; align-items: center; justify-content: center; aspect-ratio: 16 / 9; overflow: hidden; background: var(--tile-color, var(--mint)); }
.tile-art img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.tile-art svg { width: 43%; max-height: 135px; color: #253c37; opacity: .8; }
.tile-art::before, .tile-art::after { position: absolute; content: ""; border-radius: 50%; background: #fff5; width: 95px; height: 95px; }
.tile-art::before { left: -20px; bottom: -30px; }
.tile-art::after { right: -12px; top: -45px; width: 120px; height: 120px; }
.tile-art.has-thumbnail::before, .tile-art.has-thumbnail::after { display: none; }
.tile-art.has-thumbnail svg { display: none; }
.tile-status { position: absolute; bottom: 10px; left: 10px; display: inline-flex; gap: 6px; align-items: center; background: #fffdf5ee; border-radius: 20px; padding: 5px 9px; font-size: 11px; font-weight: 750; z-index: 1; }
.tile-status::before { content: ""; height: 6px; width: 6px; border-radius: 50%; background: #78a991; }
.tile-status[data-status="failed"]::before { background: #bc644e; }
.tile-status[data-status="building"]::before, .tile-status[data-status="checking"]::before { animation: pulse 1.6s ease-in-out infinite; }
.tile-copy { padding: 12px 14px 13px; }
.tile-copy h2 { font-size: 19px; letter-spacing: -.025em; margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.tile-copy p { font-size: 12px; color: var(--muted); margin: 4px 0 0; line-height: 1.4; overflow-wrap: anywhere; }
.tile-hidden { opacity: .65; }
.loading-text { margin: 80px auto; text-align: center; color: var(--muted); font-size: 15px; }
.empty-state { text-align: center; padding: 80px 20px 90px; }
.empty-controller { width: 110px; margin-bottom: 16px; transform: rotate(-9deg); }
.empty-state h2 { margin: 0; font-size: 26px; letter-spacing: -.035em; }
.empty-state p { margin: 8px 0 22px; color: var(--muted); font-size: 15px; }
.games-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: 19px 0; font-size: 13px; color: var(--muted); }
.instructor-button { margin-left: auto; }
.notice { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #f3e5b7; font-size: 13px; line-height: 1.5; }
.player-page .games-shell { max-width: none; padding: 0 18px; }
.player-page .games-header { min-height: 76px; padding: 12px 0; }
.player-page h1 { font-size: 25px; letter-spacing: -.035em; }
.player-page .games-footer { padding: 11px 0; }
.game-stage { position: relative; display: flex; align-items: stretch; justify-content: stretch; width: 100%; min-height: 300px; height: calc(100dvh - 124px); overflow: hidden; border: 1.5px solid var(--ink); border-radius: 14px; background: #e7ebdf; }
.game-stage iframe { display: block; border: 0; width: 100%; height: 100%; background: #e7ebdf; }
.game-placeholder { margin: auto; padding: 32px 24px; text-align: center; max-width: 620px; }
.status-symbol { display: inline-block; color: #78a991; font-size: 66px; line-height: 1; margin-bottom: 22px; }
.status-symbol.is-working { animation: slow-turn 5s linear infinite; }
.game-placeholder h2 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.game-placeholder p { margin: 12px 0 0; color: var(--muted); line-height: 1.6; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.build-notice { display: flex; gap: 15px; justify-content: space-between; align-items: center; background: #f1e4b9; border-radius: 10px; padding: 9px 12px; margin-bottom: 10px; }
.build-notice p { margin: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.build-notice button { flex-shrink: 0; }
.player-page:has(.build-notice:not([hidden])) .game-stage { height: calc(100dvh - 177px); }
.player-page:has(.notice:not([hidden])) .game-stage { height: calc(100dvh - 175px); }
.player-page:has(.build-notice:not([hidden])):has(.notice:not([hidden])) .game-stage { height: calc(100dvh - 225px); }
.admin-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 12px 2px 0; font-size: 12px; color: var(--muted); }
.game-dialog { width: min(680px, calc(100% - 28px)); max-height: min(90dvh, 920px); padding: 24px; border: 1.5px solid var(--ink); border-radius: 20px; background: #fffdf5; color: var(--ink); box-shadow: 0 10px 0 #253c3726, 0 28px 90px #102e312e; overscroll-behavior: contain; }
.game-dialog::backdrop { background: #193e3859; backdrop-filter: blur(3px); }
body:has(dialog[open]) { overflow: hidden; }
.compact-dialog { width: min(410px, calc(100% - 28px)); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; }
.dialog-header h2 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.04em; }
.close-dialog { font-size: 29px; font-weight: 400; margin: -7px -8px -7px 0; }
label { display: block; margin: 17px 0 7px; font-size: 13px; font-weight: 750; }
input, textarea, select { width: 100%; display: block; min-width: 0; padding: 11px 12px; border: 1.5px solid #b8c8b8; border-radius: 9px; background: #fff; color: var(--ink); font-size: 16px; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid #77bc9f; outline-offset: 1px; border-color: #467b66; }
textarea { resize: vertical; min-height: 180px; font-size: 14px; line-height: 1.65; font-family: var(--mono); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-pair label { margin-top: 0; }
.prompt-label { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; }
.prompt-label .text-button { font-size: 12px; }
.field-help { font-size: 12px; line-height: 1.6; color: var(--muted); margin: 9px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; align-items: center; margin-top: 24px; }
.draft-note { font-size: 11px; color: var(--muted); margin-right: auto; }
.form-error { background: #f9e1d6; color: #8e3826; border-radius: 8px; margin: 14px 0 0; padding: 10px 12px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.auth-tabs { display: flex; gap: 4px; background: #ecefe4; padding: 4px; border-radius: 10px; }
.auth-tab { flex: 1; border: none; border-radius: 7px; background: transparent; font-size: 14px; padding: 9px 6px; }
.auth-tab.selected { background: #fffdf5; box-shadow: 0 1px 3px #253c3721; font-weight: 750; }
.editor-dialog.expanded { width: min(1100px, calc(100% - 28px)); max-height: 95dvh; }
.editor-dialog.expanded textarea { min-height: 50dvh; }
.prompt-receipt { border-radius: 12px; background: #eff1e7; padding: 17px 20px; }
.receipt-field + .receipt-field { border-top: 1px dashed #c7cfbd; padding-top: 16px; margin-top: 16px; }
.receipt-field > span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 13px; line-height: 1.7; }
.confirm-dialog .prompt-receipt { max-height: 54dvh; overflow-y: auto; }
.prompt-history { display: grid; gap: 12px; }
.history-entry { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.history-entry summary { cursor: pointer; padding: 14px; font-size: 14px; font-weight: 750; line-height: 1.45; }
.history-entry summary small { display: block; margin: 4px 0 0 17px; color: var(--muted); font-size: 11px; font-weight: 400; }
.history-entry .prompt-receipt { border-radius: 0; }
.editor-agent-prompt-button { margin-top: 6px; font-size: 12px; }
.agent-prompt-dialog { width: min(860px, calc(100% - 28px)); }
.agent-prompt-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
.agent-prompt-dialog > :not(.agent-prompt-content) { flex-shrink: 0; }
.agent-prompt-dialog .field-help { margin-top: 0; }
#agent-prompt-jump { align-self: flex-start; margin: 5px 0 8px; }
.agent-prompt-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; margin-top: 12px; border: 1px solid #c4d7e8; border-radius: 12px; background: #f1f7fc; color: #20364d; }
.agent-prompt-content mark { color: #133a66; background: #b6e6fb; font-weight: 750; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.notification { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border: 1px solid var(--ink); background: #fffdf5; border-radius: 12px; box-shadow: 0 4px 0 #253c3726; z-index: 5; font-size: 14px; }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes slow-turn { to { transform: rotate(360deg); } }
@media (min-width: 1500px) { .player-page .games-shell { padding: 0 24px; } }
@media (max-width: 850px) { .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) {
  .games-shell { padding: 0 14px; }
  .games-header { gap: 8px; min-height: 78px; padding: 16px 0; }
  h1 { font-size: 29px; }
  .button { padding: 10px 14px; font-size: 14px; }
  .game-grid { gap: 10px; }
  .game-tile { border-radius: 13px; }
  .tile-art { aspect-ratio: 5 / 4; }
  .tile-art svg { width: 58%; }
  .tile-copy { padding: 10px; }
  .tile-copy h2 { font-size: 16px; }
  .tile-copy p { font-size: 11px; }
  .tile-status { font-size: 10px; left: 6px; bottom: 6px; padding: 4px 7px; }
  .empty-state { padding-top: 62px; }
  .player-page .games-shell { padding: 0 8px; }
  .player-page .games-header { min-height: 67px; gap: 5px; padding: 9px 0; }
  .player-page h1 { font-size: 19px; }
  .player-page .page-heading p { font-size: 10px; margin-top: 3px; }
  .player-page .header-actions { gap: 5px; }
  .player-page .header-actions .button { padding: 9px; font-size: 12px; border-radius: 9px; }
  .player-page .back-link { width: 30px; margin-left: 0; }
  .game-stage { height: calc(100dvh - 108px); border-radius: 9px; min-height: 260px; }
  .player-page:has(.build-notice:not([hidden])) .game-stage { height: calc(100dvh - 168px); }
  .player-page:has(.notice:not([hidden])) .game-stage { height: calc(100dvh - 163px); }
  .player-page:has(.build-notice:not([hidden])):has(.notice:not([hidden])) .game-stage { height: calc(100dvh - 215px); }
  .player-page .games-footer { gap: 12px; font-size: 11px; }
  .player-page .games-footer .text-button { font-size: 11px; }
  .build-notice { padding: 8px 10px; gap: 8px; }
  .build-notice p { font-size: 11px; }
  .build-notice .button { font-size: 11px; padding: 7px 9px; }
  .game-dialog { padding: 19px; border-radius: 16px; max-height: 92dvh; }
  .dialog-header h2 { font-size: 24px; }
  .field-pair { grid-template-columns: 1fr; gap: 15px; }
  .dialog-actions { flex-wrap: wrap; gap: 10px; }
  .draft-note { width: 100%; }
  .prompt-receipt { padding: 14px; }
  .game-placeholder h2 { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
