/* ==========================================================================
   RPS Arena
   8-Bit Handheld Look: NES-Titelschirm. Flache Kartonfarbe, dicke Tinte,
   harte Versatzschatten statt Weichzeichner, keine Verlaeufe, kein Glas,
   keine runden Ecken. Dial ENERGY 2 / RHYTHM 2 / MOTION 2.
   Mobile first, Portrait zuerst.
   ========================================================================== */

/* Schriften liegen lokal, kein CDN zur Laufzeit */
@font-face {
    font-family: "Press Start 2P";
    src: url("../fonts/press-start-2p-latin.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "VT323";
    src: url("../fonts/vt323-latin.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Karton und Tinte */
    --cream:      #f6f1e4;
    --cream-2:    #e9e1cd;
    --ink:        #1c1c1c;
    --ink-2:      #4c4a44;
    --ink-3:      #6d6858;

    /* Primaerfarben als Fuellungen, immer mit Tinte darauf */
    --green:      #3aa63a;
    --red:        #e5342b;
    --blue:       #2b7fd4;
    --gold:       #f4b400;

    /* Dieselben Farben als Text auf Karton, dunkel genug fuer AA */
    --green-t:    #2b7d2b;
    --red-t:      #c42a22;
    --blue-t:     #1f66b0;
    --gold-t:     #8a5f00;

    --green-wash: #dcefd8;
    --red-wash:   #f8ddd9;
    --gold-wash:  #f8ecc7;
    --blue-wash:  #d8e8f7;

    --display: "Press Start 2P", "Courier New", monospace;
    --body:    "VT323", "Courier New", monospace;

    --line:    3px;
    --pop:     4px;
    --ease:    cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; }

/* Muss die display-Regeln der Komponenten ueberschreiben */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--cream);
    color: var(--ink);
    font-family: var(--body);
    font-size: 17px;
    line-height: 1.25;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

button {
    font-family: inherit;
    color: inherit;
    border: 0;
    background: none;
    cursor: pointer;
}

/* ---------------------------------------------------------------- Bausteine */

/* Jede Karte steht auf einer harten Kante, nicht auf einem Schatten */
.chunk {
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
}

/* ---------------------------------------------------------------- App shell */

.app {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    isolation: isolate;
    background: var(--cream);
}

.fx {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 40;
}

/* Treffer-Feedback: kurzer, matter Puls statt Blitz */
.flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 45;
    opacity: 0;
    background: radial-gradient(44% 34% at 50% 46%, rgba(58, 166, 58, .18), transparent 72%);
}

.flash.is-on { animation: flash-out .4s var(--ease) both; }

@keyframes flash-out {
    0%   { opacity: 0; }
    14%  { opacity: 1; }
    100% { opacity: 0; }
}

/* Die Buehne bebt kurz beim Aufprall. Reines Feedback, kein Dauerzustand. */
.app.is-shake .arena { animation: quake .44s var(--ease); }

@keyframes quake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    18%      { transform: translate3d(-6px, 2px, 0); }
    38%      { transform: translate3d(6px, -3px, 0); }
    58%      { transform: translate3d(-4px, -1px, 0); }
    78%      { transform: translate3d(2px, 1px, 0); }
}

/* ---------------------------------------------------------------- Screens */

.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    z-index: 10;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.screen.is-active { display: flex; }

.screen--sheet {
    z-index: 30;
    background: var(--cream);
    padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
    animation: sheet-in .22s var(--ease);
}

@keyframes sheet-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- Home */

.home__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) 16px 0;
}

/* Kein Capsule-Badge: eine schlichte Statuszeile reicht. */
.home__badge {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.7;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.home__actions { display: flex; gap: 10px; }

.icon-btn {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    color: var(--ink);
    transition: transform .1s var(--ease), box-shadow .1s var(--ease);
}

.icon-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* Icons: PNG-Maske, faerbt sich ueber currentColor */
.icon-btn__glyph {
    display: block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.icon-btn--sm .icon-btn__glyph { width: 17px; height: 17px; }

.icon-btn__glyph--stats    { -webkit-mask-image: url("../img/icon-stats.png");    mask-image: url("../img/icon-stats.png"); }
.icon-btn__glyph--settings { -webkit-mask-image: url("../img/icon-settings.png"); mask-image: url("../img/icon-settings.png"); }
.icon-btn__glyph--close    { -webkit-mask-image: url("../img/icon-close.png");    mask-image: url("../img/icon-close.png"); }
.icon-btn__glyph--back     { -webkit-mask-image: url("../img/icon-back.png");     mask-image: url("../img/icon-back.png"); }

.home__hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
    padding: 22px 16px max(24px, env(safe-area-inset-bottom));
}

.brand { text-align: center; }

.brand__hands {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.brand__hand {
    display: block;
    width: 46px;
    height: 46px;
    object-fit: contain;
    /* Pixel bleiben Pixel, auch beim Verkleinern */
    image-rendering: pixelated;
    filter: drop-shadow(3px 3px 0 rgba(28, 28, 28, .8));
}

.brand__hand--mid { width: 58px; height: 58px; }

.brand__title {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(16px, 6vw, 24px);
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: 0;
    color: var(--ink);
    text-shadow: 4px 4px 0 var(--gold);
}

.brand__sub {
    margin: 12px auto 0;
    max-width: 290px;
    font-size: 17px;
    line-height: 1.3;
    color: var(--ink-2);
}

/* Setup-Bereich */

.setup { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field__label {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.7;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.field__hint {
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
    color: var(--ink-3);
    min-height: 21px;
}

.field.is-hidden { display: none; }

/* Segmentwahl: Tinte als Auswahlbalken, wie im NES-Menue */
.seg {
    display: flex;
    gap: 3px;
    padding: 3px;
    border: var(--line) solid var(--ink);
    background: var(--cream-2);
}

.seg__opt {
    flex: 1;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    text-transform: uppercase;
    color: var(--ink-2);
    transition: background .12s var(--ease), color .12s var(--ease);
}

.seg__opt.is-active {
    background: var(--ink);
    color: var(--cream);
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 12px 18px;
    font-family: var(--display);
    font-size: 10px;
    line-height: 1.6;
    text-align: center;
    color: var(--ink);
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
    transition: transform .1s var(--ease), box-shadow .1s var(--ease), background .14s var(--ease);
}

/* Der Knopf sinkt in seinen eigenen Schatten */
.btn:active {
    transform: translate(var(--pop), var(--pop));
    box-shadow: 0 0 0 var(--ink);
}

.btn--primary { background: var(--green); }
.btn--ghost   { background: var(--cream); }

.btn--danger {
    background: var(--cream);
    color: var(--red-t);
}

.btn--xl { min-height: 62px; font-size: 16px; width: 100%; }
.btn--block { width: 100%; margin-top: 4px; }

/* Tages-Challenge: reine Fortschrittsanzeige */

.daily {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 7px 12px;
    padding: 12px 14px;
    border: var(--line) solid var(--ink);
    background: var(--cream);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
}

.daily__meta { display: flex; flex-direction: column; gap: 3px; grid-column: 1 / 2; }

.daily__title {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.8;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.daily__goal { font-size: 16px; line-height: 1.2; color: var(--ink-2); }
.daily__count { font-family: var(--display); font-size: 11px; color: var(--green-t); }
.daily__count.is-done { color: var(--gold-t); }

.daily__bar {
    grid-column: 1 / 3;
    height: 14px;
    border: 2px solid var(--ink);
    background: var(--cream-2);
    overflow: hidden;
}

.daily__bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--green);
    transition: width .45s steps(6, end);
}

/* ---------------------------------------------------------------- Spiel */

.screen--game {
    padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    gap: 12px;
    overflow: hidden;
}

.hud {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-bottom: 12px;
    border-bottom: var(--line) solid var(--ink);
}

.hud__center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.hud__mode, .hud__round {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.7;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud__round { color: var(--ink-2); }

.score {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 86px;
    justify-content: center;
    padding: 9px 11px;
    font-family: var(--display);
    font-size: 15px;
    line-height: 1;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
}

.score__you { color: var(--green-t); }
.score__sep { color: var(--ink-3); }
.score__foe { color: var(--blue-t); }

.score.is-bump { animation: bump .36s steps(3, end); }

@keyframes bump {
    0%   { transform: translate(0, 0); }
    50%  { transform: translate(-3px, -3px); }
    100% { transform: translate(0, 0); }
}

/* Arena */

.arena {
    position: relative;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
        "foe vs me"
        "stage stage stage";
    align-items: center;
    justify-items: center;
    gap: 10px 8px;
    min-height: 0;
}

.side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-width: 0;
}

.side--foe { grid-area: foe; }
.side--me  { grid-area: me; }

/* Quadratischer Rahmen statt Kreis: Pixel kennen keine Rundung */
.side__disc {
    position: relative;
    width: min(100%, clamp(88px, 27vw, 132px));
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
    transition: background .2s var(--ease), border-color .2s var(--ease);
}

.side__hand {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
}

.hand__art {
    display: none;
    width: 86%;
    height: 86%;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(3px 3px 0 rgba(28, 28, 28, .55));
    animation: hand-in .34s steps(4, end) both;
}

.side__hand.has-art .hand__art { display: block; }
.side__hand.has-art .hand__mark { display: none; }

@keyframes hand-in {
    from { opacity: 0; transform: scale(.7); }
    to   { opacity: 1; transform: scale(1); }
}

.hand__mark {
    font-family: var(--display);
    font-size: clamp(24px, 8vw, 34px);
    line-height: 1;
    color: var(--ink-3);
}

.side__disc.is-shaking .side__hand { animation: shake .4s steps(2, end) infinite; }

@keyframes shake {
    0%, 100% { transform: rotate(-7deg) translateY(1px); }
    50%      { transform: rotate(7deg) translateY(-3px); }
}

.side__disc.is-pop { animation: pop .4s steps(4, end); }

@keyframes pop {
    0%   { transform: scale(.74); }
    60%  { transform: scale(1.09); }
    100% { transform: scale(1); }
}

/* Ergebnisse: Zustandsfarbe des Rahmens, kein Leuchten */
.side__disc.is-win {
    background: var(--green-wash);
    border-color: var(--green-t);
}

.side__disc.is-lose {
    border-color: var(--ink-3);
    opacity: .55;
}

/* Graustufen muessen auf dem Bild liegen, nicht auf dem Wrapper */
.side__disc.is-lose .hand__art {
    filter: drop-shadow(3px 3px 0 rgba(28, 28, 28, .4)) grayscale(1);
}

.side__disc.is-draw {
    background: var(--gold-wash);
    border-color: var(--gold-t);
}

.side__info { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }

/* Namensschild: Farbe traegt die Bedeutung, wer hier steht */
.side__name {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    text-transform: uppercase;
    padding: 5px 8px;
    color: var(--ink);
    border: 2px solid var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
}

.side--me .side__name  { background: var(--green); }
.side--foe .side__name { background: var(--blue); }

.side__state {
    font-size: 15px;
    line-height: 1.25;
    color: var(--ink-3);
    min-height: 19px;
}

/* VS-Marke zwischen den beiden Seiten */
.arena__vs {
    grid-area: vs;
    align-self: center;
    padding: 7px 6px;
    font-family: var(--display);
    font-size: 10px;
    line-height: 1;
    color: var(--ink);
    background: var(--red);
    border: var(--line) solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
}

/* Buehne / Countdown */

.stage {
    grid-area: stage;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 40px;
    width: 100%;
}

.countdown {
    font-family: var(--display);
    font-size: clamp(34px, 13vw, 52px);
    line-height: 1.2;
    color: var(--ink);
    text-shadow: 5px 5px 0 var(--gold);
    opacity: 0;
    transform: scale(.6);
    pointer-events: none;
}

.countdown.is-show { animation: count .62s steps(5, end) both; }

@keyframes count {
    0%   { opacity: 0; transform: scale(.55); }
    22%  { opacity: 1; transform: scale(1.05); }
    70%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.3); }
}

.banner {
    font-family: var(--display);
    font-size: 9px;
    line-height: 1.8;
    text-align: center;
    color: var(--ink);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .22s var(--ease), transform .22s var(--ease);
    padding: 0 4px;
}

.banner.is-show { opacity: 1; transform: none; }
.banner.is-win  { color: var(--green-t); }
.banner.is-lose { color: var(--red-t); }
.banner.is-draw { color: var(--gold-t); }

.banner small {
    display: block;
    margin-top: 6px;
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.25;
    text-transform: none;
    color: var(--ink-3);
}

.next-btn { font-size: 9px; animation: fade-up .22s var(--ease); }

@keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* Streak: eine Textzeile, kein Capsule-Badge */

.streak {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    align-self: center;
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.7;
    text-transform: uppercase;
    color: var(--ink-2);
    flex-shrink: 0;
    animation: fade-up .22s var(--ease);
}

.streak__flame { font-size: 9px; color: var(--ink-3); }
.streak.is-hot { color: var(--gold-t); }
.streak.is-hot .streak__flame { color: var(--gold-t); }

/* Auswahlkarten */

.choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    flex-shrink: 0;
    transition: opacity .24s var(--ease);
}

.choices.is-locked { opacity: .45; pointer-events: none; }

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 6px 9px;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
    touch-action: manipulation;
    transition: transform .1s var(--ease), box-shadow .1s var(--ease), background .16s var(--ease);
}

/* Nur bei echten Zeigegeraeten, sonst bleibt der Hover auf Touch kleben */
@media (hover: hover) {
    .card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
    .card:hover .card__icon { transform: scale(1.06); }
}

.card:active { transform: translate(var(--pop), var(--pop)); box-shadow: 0 0 0 var(--ink); }

/* Gewaehlt heisst eingedrueckt und gruen, wie ein gedrueckter Knopf */
.card.is-selected {
    background: var(--green);
    transform: translate(var(--pop), var(--pop));
    box-shadow: 0 0 0 var(--ink);
}

.card__disc {
    display: grid;
    place-items: center;
    width: clamp(38px, 12vw, 50px);
    aspect-ratio: 1;
    background: var(--cream);
    border: 2px solid var(--ink);
}

.card__icon {
    width: 88%;
    height: 88%;
    object-fit: contain;
    image-rendering: pixelated;
    transition: transform .12s var(--ease);
}

.card.is-selected .card__icon { transform: scale(1.1); }

.card__label {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    text-transform: uppercase;
    color: var(--ink);
}

/* Tastenkuerzel: echte Funktion, kein Schmuck */
.card__key {
    position: absolute;
    top: 5px;
    right: 5px;
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    padding: 1px 4px;
    color: var(--cream);
    background: var(--ink);
}

/* ---------------------------------------------------------------- Sheets */

.sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(16px, env(safe-area-inset-top)) 0 14px;
    border-bottom: var(--line) solid var(--ink);
    flex-shrink: 0;
}

.sheet__title {
    margin: 0;
    font-family: var(--display);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.7;
    text-transform: uppercase;
}

.sheet__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 0 max(26px, env(safe-area-inset-bottom));
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 4px;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
}

.stat__v { font-family: var(--display); font-size: 14px; line-height: 1.4; }
.stat__k {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
    text-align: center;
}

.stat--win  .stat__v { color: var(--green-t); }
.stat--lose .stat__v { color: var(--red-t); }

.panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
}

.panel__title {
    margin: 0;
    font-family: var(--display);
    font-size: 8px;
    font-weight: 400;
    line-height: 1.8;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink);
}

.panel__note { margin: 0; font-size: 16px; line-height: 1.3; color: var(--ink-3); }

.bars { display: flex; flex-direction: column; gap: 10px; }

.bar-row { display: grid; grid-template-columns: 64px 1fr 34px; align-items: center; gap: 10px; }

.bar-row__k {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    text-transform: uppercase;
    color: var(--ink-2);
}

.bar-row__track {
    height: 14px;
    border: 2px solid var(--ink);
    background: var(--cream-2);
    overflow: hidden;
}

.bar-row__fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--green);
    transition: width .45s steps(6, end);
}

.bar-row__v { font-size: 16px; line-height: 1.2; text-align: right; color: var(--ink-3); }

.readout { display: flex; align-items: center; gap: 12px; }

.readout__v {
    font-family: var(--display);
    font-size: 13px;
    line-height: 1.4;
    color: var(--blue-t);
    min-width: 58px;
}

.readout__bar {
    flex: 1;
    height: 14px;
    border: 2px solid var(--ink);
    background: var(--cream-2);
    overflow: hidden;
}

.readout__bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--blue);
    transition: width .45s steps(6, end);
}

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.board__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 2px solid var(--cream-2);
    font-size: 16px;
    line-height: 1.25;
}

.board__row:last-child { border-bottom: 0; }
.board__rank { font-family: var(--display); font-size: 8px; color: var(--ink-3); width: 22px; }
.board__name { flex: 1; color: var(--ink-2); }
.board__tag { font-size: 15px; color: var(--ink-3); }
.board__tag.is-win  { color: var(--green-t); }
.board__tag.is-lose { color: var(--red-t); }
.board__tag.is-draw { color: var(--gold-t); }

.board__empty { padding: 10px 0; font-size: 16px; color: var(--ink-3); }

/* Toggles: eckiger Schalter statt Badge-Kapsel */

.toggle {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
    cursor: pointer;
}

.toggle__text { flex: 1; display: flex; flex-direction: column; gap: 3px; }

.toggle__text b {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.8;
    font-weight: 400;
    text-transform: uppercase;
}

.toggle__text small { font-size: 15px; line-height: 1.25; color: var(--ink-3); }

.toggle input { position: absolute; opacity: 0; pointer-events: none; }

.toggle__switch {
    position: relative;
    flex-shrink: 0;
    width: 56px;
    height: 32px;
    background: var(--cream-2);
    border: var(--line) solid var(--ink);
    transition: background .14s var(--ease);
}

.toggle__switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--ink);
    transition: transform .14s steps(2, end);
}

.toggle input:checked ~ .toggle__switch { background: var(--green); }
.toggle input:checked ~ .toggle__switch::after { transform: translateX(24px); }
.toggle input:focus-visible ~ .toggle__switch { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------------------------------------------------------------- Overlays */

/* Kein Glas: harter Vorhang ueber dem Spielfeld */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(28, 28, 28, .74);
    animation: overlay-in .18s var(--ease);
}

.overlay[hidden] { display: none; }

@keyframes overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.overlay__card {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 18px;
    text-align: center;
    background: var(--cream);
    border: 5px solid var(--ink);
    animation: card-in .24s steps(4, end);
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px) scale(.96); }
    to   { opacity: 1; transform: none; }
}

.overlay__kicker {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.8;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.overlay__title {
    margin: 0;
    font-family: var(--display);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.8;
    text-transform: uppercase;
}

.overlay__title.is-win  { color: var(--green-t); }
.overlay__title.is-lose { color: var(--red-t); }
.overlay__title.is-draw { color: var(--gold-t); }

.overlay__text { margin: 0; font-size: 17px; line-height: 1.3; color: var(--ink-2); }

.overlay__stats { display: flex; justify-content: center; gap: 22px; padding: 6px 0 2px; }

.overlay__stats div { display: flex; flex-direction: column; gap: 4px; }

.overlay__stats b {
    font-family: var(--display);
    font-size: 13px;
    line-height: 1.4;
}

.overlay__stats span {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.overlay__actions { display: flex; gap: 10px; margin-top: 4px; }
.overlay__actions .btn { flex: 1; }

.overlay__card .btn--primary { margin-top: 4px; }

/* Knapper Sieg / Comeback: nur die Kante wird betont */
.overlay__card--result.is-epic { border-color: var(--gold); }

/* ---------------------------------------------------------------- Responsive */

@media (min-width: 620px) {
    .home__hero { max-width: 450px; }
    .screen--game { padding: max(18px, env(safe-area-inset-top)) 30px max(20px, env(safe-area-inset-bottom)); }

    /* Desktop wird mit der Maus bedient, dort darf die Wahl flacher sein */
    .seg__opt { min-height: 38px; }

    .arena {
        grid-template-columns: 1fr auto 1fr;
        grid-template-areas:
            "foe vs me"
            "stage stage stage";
        gap: 16px;
    }

    .side__disc { width: clamp(104px, 15vw, 140px); }
    .choices { max-width: 520px; width: 100%; margin: 0 auto; gap: 14px; }
    .card { padding: 14px 10px 12px; }
    .stat-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (min-width: 900px) {
    .home__hero { gap: 26px; }
    .brand__hands { gap: 16px; }
    .brand__hand { width: 54px; height: 54px; }
    .brand__hand--mid { width: 66px; height: 66px; }
    .brand__title { font-size: 26px; }
}

/* Kurze Viewports (Handy quer / kleine Hoehen) */
@media (max-height: 700px) {
    .side__disc { width: min(100%, clamp(68px, 21vw, 100px)); }
    .card { padding: 7px 5px 7px; gap: 5px; }
    .card__disc { width: clamp(32px, 10vw, 40px); }
    .card__label { font-size: 8px; }
    .home__hero { gap: 14px; padding-top: 8px; padding-bottom: 12px; }
    .brand__hands { gap: 8px; margin-bottom: 10px; }
    .brand__hand { width: 34px; height: 34px; }
    .brand__hand--mid { width: 42px; height: 42px; }
    .brand__title { font-size: 15px; text-shadow: 3px 3px 0 var(--gold); }
    .brand__sub { margin-top: 8px; font-size: 15px; }
    .setup { gap: 10px; }
    .seg__opt { min-height: 38px; }
    .btn--xl { min-height: 52px; font-size: 13px; }
    .daily { padding: 9px 12px; }
    .field__hint { font-size: 15px; min-height: 19px; }
    .banner { font-size: 8px; }
}

@media (max-height: 640px) and (orientation: landscape) {
    .arena {
        grid-template-columns: 1fr auto 1fr 1fr;
        grid-template-areas: "foe vs me stage";
    }
    .side__disc { width: min(100%, clamp(62px, 16vh, 92px)); }
    .choices { max-width: 430px; margin: 0 auto; width: 100%; }
}

/* ---------------------------------------------------------------- A11y */

:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* Nutzer-Schalter "Animations aus" */
.app.no-motion *, .app.no-motion *::before, .app.no-motion *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .05s !important;
}

/* ---------------------------------------------------------------- Bildroehre */

/* Angedeutete Roehre: feine Scanlines, leichter Randabfall, minimales Flimmern.
   Bewusst sehr leise, damit Schrift und Farben sauber lesbar bleiben. */
.crt {
    position: fixed;
    inset: 0;
    z-index: 55;
    pointer-events: none;
}

.crt::before,
.crt::after {
    content: "";
    position: absolute;
    inset: 0;
}

/* Scanlines */
.crt::before {
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(28, 28, 28, .05) 0 1px,
        rgba(28, 28, 28, 0) 1px 3px
    );
    animation: crt-flicker 7s steps(2, end) infinite,
               crt-scroll 1.6s linear infinite;
}

/* Scanlines wandern langsam nach unten: eine Periode (3px), dadurch nahtlos */
@keyframes crt-scroll {
    from { background-position: 0 0; }
    to   { background-position: 0 3px; }
}

/* Rohrenrand plus Streiflicht von oben, wie auf gewoelbtem Glas */
.crt::after {
    background:
        radial-gradient(120% 62% at 50% 0%, rgba(246, 241, 228, .2), rgba(246, 241, 228, 0) 62%),
        radial-gradient(132% 108% at 50% 50%, rgba(28, 28, 28, 0) 60%, rgba(28, 28, 28, .16) 100%);
}

@keyframes crt-flicker {
    0%, 100% { opacity: .86; }
    50%      { opacity: 1; }
}

/* ---------------------------------------------------------------- Spielwahl */

/* Modul-Zeile auf der Startseite: wie ein Spielmodul, das man einlegt */
.rom {
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(100% - 32px);
    max-width: 430px;
    margin: 14px auto 0;
    padding: 11px 13px;
    text-align: left;
    background: var(--cream);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
    transition: transform .1s var(--ease), box-shadow .1s var(--ease), background .14s var(--ease);
}

.rom:active {
    transform: translate(var(--pop), var(--pop));
    box-shadow: 0 0 0 var(--ink);
}

@media (hover: hover) {
    .rom:hover { background: var(--cream-2); }
}

/* Vorschau des Bretts, reines CSS: die Diagonale zeigt "drei in einer Reihe" */
.rom__art {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 42px;
    height: 42px;
    padding: 2px;
    background: var(--ink);
}

.rom__art i { display: block; background: var(--cream); }
.rom__art i.is-on { background: var(--green); }

.rom__body { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.rom__title {
    font-family: var(--display);
    font-size: 10px;
    line-height: 1.5;
    text-transform: uppercase;
    color: var(--ink);
}

.rom__meta { font-size: 15px; line-height: 1.2; color: var(--ink-3); }

.rom__go {
    flex-shrink: 0;
    font-family: var(--display);
    font-size: 10px;
    line-height: 1;
    color: var(--ink-3);
}

/* ---------------------------------------------------------------- Tic Tac Toe */

.screen--ttt {
    padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    gap: 12px;
}

.ttt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 0;
}

/* Das Brett richtet sich auch nach der Hoehe, damit nichts abgeschnitten wird */
.ttt__board {
    display: grid;
    /* Feste 3x3-Rasterlinien: ohne 1fr-Zeilen zieht die markierte Zeile
       auf ihre Inhaltshoehe und die Felder werden Rechtecke. */
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
    width: min(100%, 336px, 44vh);
    aspect-ratio: 1;
    padding: 6px;
    background: var(--cream-2);
    border: var(--line) solid var(--ink);
    box-shadow: var(--pop) var(--pop) 0 var(--ink);
}

.ttt__cell {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    background: var(--cream);
    border: 2px solid var(--ink);
    font-family: var(--display);
    font-size: clamp(22px, 9vw, 40px);
    line-height: 1;
    color: var(--ink);
    transition: background .12s var(--ease);
}

.ttt__cell.is-x { color: var(--green-t); }
.ttt__cell.is-o { color: var(--blue-t); }
.ttt__cell.is-set { animation: pop .3s steps(4, end); }
.ttt__cell.is-win { background: var(--gold-wash); }
.ttt__cell:disabled { cursor: default; }

@media (hover: hover) {
    .ttt__cell:not(:disabled):hover { background: var(--cream-2); }
}

.ttt__status {
    margin: 0;
    min-height: 23px;
    font-size: 18px;
    line-height: 1.25;
    text-align: center;
    color: var(--ink-2);
}

.ttt__status.is-win  { color: var(--green-t); }
.ttt__status.is-lose { color: var(--red-t); }
.ttt__status.is-draw { color: var(--gold-t); }

.ttt__meta {
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.7;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
    text-align: center;
}

.ttt__panel { width: 100%; max-width: 430px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

/* Knopfreihe: erst der Weiter-Knopf ueber die volle Breite, dann zwei gleich breite */
.ttt__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ttt__actions .btn { flex: 1 1 46%; }
.ttt__actions .ttt__next { flex: 1 1 100%; }
.ttt__actions .btn--primary { margin-top: 0; }

/* Segmentwahl der zweiten Spielart: gleiche Geometrie wie .seg, eigener Name,
   damit sich die Ereignisse des RPS-Menues nicht einmischen */
.pick {
    display: flex;
    gap: 3px;
    padding: 3px;
    border: var(--line) solid var(--ink);
    background: var(--cream-2);
}

.pick__opt {
    flex: 1;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    font-family: var(--display);
    font-size: 8px;
    line-height: 1.6;
    text-transform: uppercase;
    color: var(--ink-2);
    transition: background .12s var(--ease), color .12s var(--ease);
}

.pick__opt.is-active {
    background: var(--ink);
    color: var(--cream);
}

@media (min-width: 620px) {
    .screen--ttt { padding: max(18px, env(safe-area-inset-top)) 30px max(20px, env(safe-area-inset-bottom)); }
    .ttt__board { width: min(100%, 400px, 50vh); gap: 6px; }
    .ttt__cell { font-size: 44px; }
}

@media (max-height: 700px) {
    .ttt__board { width: min(100%, 280px, 40vh); }
    .ttt__status { font-size: 16px; min-height: 20px; }
    .screen--ttt .setup { gap: 10px; }
    .ttt__cell { font-size: clamp(20px, 8vw, 32px); }

    /* Kurze Handys: Modulzeile flacher, Schrift bleibt ueber 8px */
    .rom { gap: 10px; margin-top: 10px; padding: 8px 10px; }
    .rom__art { width: 34px; height: 34px; }
    .rom__meta { font-size: 14px; }
}
