:root {
    color-scheme:light;
    --paper:#f4efe6;
    --ink:#242a26;
    --muted:#62695f;
    --accent:#a44223;
    --line:#d8d8c9;
    --panel:#ebe8de;
    --card:rgba(255,255,255,.35);
    --button-text:#fff;
}

* {
    box-sizing:border-box;
}

html {
    scroll-behavior:smooth;
    scroll-padding-top:24px;
}

body {
    margin:0;
    background:var(--paper);
    color:var(--ink);
    font-family:"Noto Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    line-height:1.8;
}

a {
    color:inherit;
    text-underline-offset:5px;
}

a:focus-visible,summary:focus-visible,button:focus-visible,select:focus-visible {
    outline:3px solid var(--accent);
    outline-offset:6px;
}

img {
    max-width:100%;
    display:block;
}

.wrap {
    width:min(1200px,calc(100% - 80px));
    margin-inline:auto;
}

.site-header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:24px;
    border-bottom:1px solid var(--line);
    padding:26px 0;
}

.brand {
    font-size:15px;
    letter-spacing:.09em;
    font-weight:800;
    text-decoration:none;
}

.brand span {
    display:block;
    font-size:10px;
    letter-spacing:.1em;
    font-weight:400;
    color:var(--muted);
}

nav {
    display:flex;
    gap:26px;
    font-size:13px;
}

nav a {
    text-decoration:none;
}

.hero {
    padding:76px 0 64px;
}

.eyebrow {
    font-size:11px;
    font-weight:700;
    letter-spacing:.16em;
    color:var(--muted);
}

h1 {
    font-size:clamp(40px,5.8vw,76px);
    line-height:1.25;
    letter-spacing:-.045em;
    margin:26px 0 30px;
}

h1 span {
    color:var(--accent);
}

.hero-bottom {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:24px;
}

.hero-bottom p {
    margin:0;
    color:var(--muted);
    font-size:15px;
}

.button {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:28px;
    padding:12px 23px;
    border-radius:5px;
    text-decoration:none;
    font-size:14px;
    font-weight:650;
}

.primary {
    background:var(--ink);
    color:var(--button-text);
}

.primary:hover {
    background:var(--accent);
}

.section-heading {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:16px;
    border-top:1px solid var(--line);
    padding:25px 0;
}

h2 {
    margin:0;
    font-size:20px;
}

h2 span {
    font-size:12px;
    color:var(--muted);
    font-weight:400;
    margin-left:16px;
}

.game {
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:48px;
    padding:22px 0 58px;
    margin-bottom:32px;
    border-bottom:1px solid var(--line);
    align-items:start;
}

.game-visual {
    position:sticky;
    top:24px;
    min-width:0;
    border-radius:8px;
    overflow:hidden;
    color:#fff;
    padding:22px 22px 10px;
}

.visual-label {
    display:flex;
    justify-content:space-between;
    gap:10px;
    font-size:10px;
    letter-spacing:.15em;
    margin-bottom:26px;
}

.game-visual img {
    width:100%;
    height:auto;
    object-fit:contain;
    border-radius:3px;
    background:rgba(0,0,0,.2);
}

.game-visual>p {
    font-size:10px;
    letter-spacing:.15em;
    margin:22px 0 12px;
}

.island {
    background:#205b51;
}

.hacker {
    background:#092c32;
    color:#81e8e0;
}

.rat {
    background:radial-gradient(ellipse at 80% 20%,#564465,transparent 65%),#151922;
    color:#e4ddf0;
}

.rat-title {
    padding:36px 12px 46px;
    border-block:1px solid #786889;
}

.rat-title span {
    font-size:10px;
    letter-spacing:.16em;
    color:#d1c8d7;
}

.rat-title p {
    font-family:Georgia,serif;
    font-size:clamp(60px,7vw,96px);
    line-height:1.05;
    margin:20px 0 25px;
}

.rat-title em {
    color:#c5a5e7;
    font-weight:400;
}

.game-copy {
    min-width:0;
}

.game-copy>.eyebrow {
    margin:0 0 7px;
}

h3 {
    font-size:34px;
    line-height:1.2;
    letter-spacing:-.025em;
    margin:0 0 20px;
}

.game-copy p {
    font-size:14px;
    color:var(--muted);
}

.game-copy .lead {
    font-size:18px;
    color:var(--ink);
    font-weight:600;
    margin-top:0;
}

.how-to {
    margin:24px 0;
    padding:20px;
    background:var(--panel);
    border-radius:5px;
}

.how-to h4 {
    margin:0 0 8px;
    font-size:13px;
}

.how-to ul {
    padding-left:20px;
    margin:0;
    font-size:13px;
}

.actions {
    display:flex;
    gap:22px;
    align-items:center;
    flex-wrap:wrap;
    margin-bottom:26px;
}

.text-link {
    font-size:13px;
    font-weight:600;
}

details {
    border-top:1px solid var(--line);
    padding:12px 0;
    font-size:13px;
}

summary {
    cursor:pointer;
    font-weight:600;
}

details p {
    margin-bottom:8px;
}

.credit {
    font-size:11px!important;
    margin-top:20px;
    color:var(--muted);
}

iframe {
    display:block;
    width:100%;
    aspect-ratio:16/9;
    border:0;
    margin-top:16px;
}

.table-scroll {
    overflow-x:auto;
}

table {
    border-collapse:collapse;
    width:100%;
    font-size:12px;
    text-align:left;
}

th,td {
    padding:6px;
    border-bottom:1px solid var(--line);
}

thead th {
    color:var(--muted);
    font-weight:400;
}

tbody th {
    font-weight:500;
}

code {
    font-size:.95em;
}

.game-copy h3 small {
    display: block;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--muted);
    margin-top: 10px;
}
.classics {
    padding-bottom: 60px;
}
.classic-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}
.classic-card {
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:var(--card);
}
.classic-card h3 {
    font-size: 25px;
    line-height: 1.4;
}
.classic-card p {
    font-size: 14px;
    color: var(--muted);
}
.classic-card .eyebrow {
    font-size: 11px;
    margin-top: 0;
}
.classic-card .classic-lead {
    color: var(--ink);
    font-weight: 600;
}
.classic-card .how-to p {
    margin: 0;
    font-size: 13px;
}
.archive {
    padding:8px 0 66px;
}

.archive .section-heading {
    border:0;
    padding-top:0;
}

.archive-intro {
    font-size:14px;
    color:var(--muted);
    margin:0 0 32px;
}

.archive-grid {
    display:grid;
    grid-template-columns:repeat(3,1fr);
    list-style:none;
    padding:0;
    margin:0;
    border-top:1px solid var(--line);
    border-left:1px solid var(--line);
}

.archive-grid li {
    display:flex;
    gap:18px;
    align-items:baseline;
    border-right:1px solid var(--line);
    border-bottom:1px solid var(--line);
    padding:25px 22px;
}

.archive-grid li>span {
    font-size:10px;
    color:var(--accent);
}

.archive-grid h3 {
    font-size:18px;
    margin:0;
    letter-spacing:0;
    line-height:1.6;
}

.archive-grid small {
    display:block;
    font-size:12px;
    font-weight:400;
    color:var(--muted);
}

footer {
    border-top:1px solid var(--line);
    padding:32px 0;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:22px;
}

footer p {
    font-size:12px;
    color:var(--muted);
    margin:0;
}

footer p span {
    display:block;
    font-size:10px;
}

footer>a:last-child {
    font-size:12px;
}

.skip-link {
    position:absolute;
    left:12px;
    top:-100px;
    background:var(--paper);
    padding:10px;
    z-index:10;
}

.skip-link:focus {
    top:12px;
}

.sr-only {
    position:absolute;
    width:1px;
    height:1px;
    overflow:hidden;
    clip-path:inset(50%);
    white-space:nowrap;
}

@media(min-width:1400px) {
    .hero {
        padding-top:90px;
    }
}

@media(max-width:850px) {
    .wrap {
        width:calc(100% - 40px);
    }
    .game {
        gap:28px;
    }
    .game-visual {
        padding:16px;
    }
    nav {
        gap:16px;
    }
    .archive-grid {
        grid-template-columns:repeat(2,1fr);
    }
    h3 {
        font-size:29px;
    }
    .hero {
        padding:50px 0;
    }
}

@media(max-width:620px) {
    .classic-grid {
        grid-template-columns: 1fr;
    }
    .classic-card {
        padding: 22px;
    }
    nav {
        flex-wrap: wrap;
    }
    .site-header {
        align-items:flex-start;
        flex-direction:column;
        gap:16px;
        padding:20px 0;
    }
    nav {
        width:100%;
        justify-content:space-between;
    }
    .hero {
        padding:42px 0;
    }
    .hero-bottom {
        align-items:flex-start;
        flex-direction:column;
    }
    .hero-bottom p {
        font-size:14px;
    }
    h1 {
        font-size:42px;
    }
    .section-heading h2 span {
        display:block;
        margin:2px 0 0;
    }
    .game {
        grid-template-columns:1fr;
        gap:28px;
        margin-bottom:20px;
        padding-bottom:34px;
    }
    .game-visual {
        position:static;
    }
    .game-visual img {
        max-height:340px;
    }
    .rat-title {
        padding:20px 10px;
    }
    .rat-title p {
        font-size:64px;
    }
    .archive-grid li {
        padding:20px 12px;
        gap:10px;
    }
    .archive-grid h3 {
        font-size:15px;
    }
    footer {
        align-items:flex-start;
        flex-direction:column;
    }
    .actions {
        gap:18px;
    }
    .archive {
        padding-bottom:40px;
    }
}

@media(prefers-reduced-motion:reduce) {
    html {
        scroll-behavior:auto;
    }
}

/* Theme tokens keep cards, controls, text, and focus indicators consistent. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #171c1a;
    --ink: #edf0e9;
    --muted: #b1bab0;
    --accent: #f5ac87;
    --line: #3b4840;
    --panel: #242e28;
    --card: #1e2621;
    --button-text: #171c1a;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
        --paper: #171c1a;
        --ink: #edf0e9;
        --muted: #b1bab0;
        --accent: #f5ac87;
        --line: #3b4840;
        --panel: #242e28;
        --card: #1e2621;
        --button-text: #171c1a;
    }
}
.site-header {
    flex-wrap: wrap;
}
.preferences {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    font-size: 12px;
}
.preferences[hidden] {
    display: none;
}
.preferences .preference-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font: inherit;
    font-weight: 600;
    background: var(--panel);
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px;
    min-height: 44px;
    cursor: pointer;
}
.preference-toggle span {
    display: grid;
    place-items: center;
    min-width: 36px;
    height: 34px;
    border-radius: 999px;
    line-height: 1;
}
.preference-toggle[data-active="first"] span:first-child,
.preference-toggle[data-active="second"] span:last-child {
    background: var(--ink);
    color: var(--button-text);
}
.preference-toggle:hover {
    border-color: var(--accent);
}
#theme-toggle span {
    font-size: 22px;
}
html[lang="en"] .section-heading h2 span {
    display: block;
    margin-left: 0;
}
@media (max-width: 620px) {
    .preferences {
        margin-left: 0;
    }
    nav {
        column-gap: 18px;
        row-gap: 10px;
        justify-content: flex-start;
    }
}

/* Every game belongs to one collection and uses the same image-led card. */
.games-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    align-items: stretch;
    padding-bottom: 64px;
}
.game-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
}
.game-cover {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.game-card .game-copy {
    padding: 26px;
}
.game-card h3 {
    font-size: 28px;
    line-height: 1.3;
}
.game-card .classic-lead {
    color: var(--ink);
    font-weight: 600;
    font-size: 18px;
}
.game-card .how-to p {
    margin: 0;
    font-size: 13px;
}
@media (max-width: 700px) {
    .games-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .game-card .game-copy {
        padding: 22px;
    }
}

/* Match collapsed card dimensions; expanded content remains fully readable. */
.game-card {
    display: flex;
    flex-direction: column;
}
.game-cover {
    flex: none;
}
.game-card .game-copy {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 340px;
}
.card-heading {
    min-height: 116px;
}
.card-heading .eyebrow {
    margin: 0 0 7px;
}
.card-heading h3 {
    margin: 0 0 14px;
}
.game-card .lead, .game-card .classic-lead {
    margin: 0 0 22px;
}
.card-details {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    padding-bottom: 0;
}
.details-trigger {
    padding: 6px 0;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: start;
}
.details-trigger:hover {
    text-decoration: underline;
    text-underline-offset: 5px;
}
.game-popover {
    width: min(640px, calc(100% - 32px));
    max-height: calc(100dvh - 48px);
    margin: auto;
    padding: 24px;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 20px 80px rgba(0, 0, 0, .25);
}
.game-popover::backdrop {
    background: rgba(0, 0, 0, .35);
}
.popover-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.popover-heading h3 {
    margin: 0;
}
.popover-close {
    flex: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.popover-close:hover {
    border-color: var(--accent);
}
.download-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}
.store-badge {
    display: inline-flex;
    width: 144px;
    height: 48px;
    flex: 0 0 144px;
    border-radius: 7px;
}
.store-badge img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.store-badge:hover {
    opacity: .8;
}
.store-badge:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}
.web-badge {
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid #a6a6a6;
    background: #000;
    color: #fff;
    text-decoration: none;
}
.web-badge:hover {
    color: #fff;
}
.web-badge svg {
    flex: none;
}
.web-badge-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1;
}
.web-badge-label {
    font-size: 9px;
    letter-spacing: .5px;
}
.web-badge-title {
    font-size: 18px;
    font-weight: 700;
}
.card-details > summary {
    color: var(--accent);
    padding-block: 6px;
}
.card-expanded {
    padding-top: 12px;
}
.card-expanded .actions {
    margin-block: 20px;
}
@media (max-width: 700px) {
    .game-card .game-copy {
        min-height: 340px;
    }
}

/* Match the Strait Defense cover to the selected page language. */
.cover-en {
    display: none;
}
html[lang="en"] .cover-zh {
    display: none;
}
html[lang="en"] .cover-en {
    display: block;
}

/* Keep the same collection and platform order in either view. */
#collection > .section-heading {
    flex-wrap: wrap;
    gap: 16px;
}
.collection-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}
.view-switch {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}
.view-switch[hidden] {
    display: none;
}
.view-switch button {
    min-height: 44px;
    padding: 8px 14px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.view-switch button[aria-pressed="true"] {
    background: var(--accent);
    color: var(--button-text);
}
html[data-view="list"] .games-grid {
    grid-template-columns: 1fr;
    gap: 16px;
}
html[data-view="list"] .game-card {
    display: grid;
    grid-template-columns: minmax(0, 32%) minmax(0, 1fr);
    align-items: start;
}
html[data-view="list"] .game-cover {
    border-bottom: 0;
}
html[data-view="list"] .game-copy {
    min-height: 0;
    min-width: 0;
    padding: 22px;
}
html[data-view="list"] .card-heading {
    min-height: 0;
}
html[data-view="list"] .card-details {
    margin-top: 0;
}
html[data-view="list"] .lead,
html[data-view="list"] .classic-lead,
html[data-view="list"] .download-links {
    margin-bottom: 14px;
}
@media (max-width: 700px) {
    html[data-view="list"] .game-card {
        grid-template-columns: 96px minmax(0, 1fr);
    }
    html[data-view="list"] .game-cover {
        margin-top: 16px;
    }
    html[data-view="list"] .game-copy {
        padding: 16px 12px;
    }
    html[data-view="list"] .game-card h3 {
        font-size: 21px;
    }
}

/* Hidden cards stay hidden when list view gives cards an explicit display. */
html .game-card[hidden] {
    display: none;
}

/* Compact launcher: the original card layout is available as Tiles. */
.launcher-grid { display: none; }
html[data-view="grid"][data-launcher-ready="true"] .games-grid { display: none; }
html[data-view="grid"] .launcher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
    gap: 28px 24px;
    padding: 24px 0 64px;
}
.launcher-game {
    min-width: 0; padding: 0; border: 0; background: transparent;
    color: var(--ink); font: inherit; cursor: pointer; text-align: center;
    border-radius: 20px;
}
.launcher-artwork {
    display: block; aspect-ratio: 1; overflow: hidden;
    border: 1px solid var(--line); border-radius: 22%;
    background: var(--panel); box-shadow: 0 5px 12px #00000014;
    transition: transform .18s ease, box-shadow .18s ease;
}
.launcher-artwork .game-cover {
    width: 100%; height: 100%; aspect-ratio: 1;
    object-fit: contain; object-position: center; padding: 8%; border: 0;
}
.launcher-artwork .launcher-icon { padding: 0; }
.launcher-title { display: block; margin-top: 12px; font-size: 15px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.launcher-title small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }
.launcher-game:hover .launcher-artwork { transform: translateY(-4px); box-shadow: 0 10px 22px #00000024; }
.launcher-game:active .launcher-artwork { transform: scale(.96); }
.launcher-game:focus-visible { outline: 3px solid var(--accent); outline-offset: 6px; }
.launcher-dialog .launcher-artwork { width: 120px; margin: 20px 0; }
.launcher-dialog .download-links { margin-top: 20px; }
.launcher-dialog .lead, .launcher-dialog .classic-lead { line-height: 1.6; }
@media (max-width: 700px) {
    html[data-view="grid"] .launcher-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 14px; }
    .launcher-title { font-size: 13px; }
    .launcher-title small { font-size: 11px; }
    .view-switch button { padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) {
    .launcher-artwork { transition: none; }
}
