/* =====================================================================
   BREAK THE CODE — "Playful Tabletop" design system
   Shared tokens + base + landing page (index.html)
   ===================================================================== */

/* ---------- Design tokens ---------- */
:root {
    /* Clean green tabletop palette — matches the real game (green / white / black) */
    --paper: #E7F0E5;
    --paper-2: #F1F8EE;
    --surface: #FFFFFF;
    --surface-2: #F5FBF3;
    --surface-sunken: #EAF3E7;

    --ink: #1B2A22;
    --ink-2: #46554D;
    --muted: #788A7E;
    --line: #D1E2D1;
    --line-strong: #B4CEB5;

    /* Green-forward accents */
    --brand: #15B677;
    --brand-ink: #0A6E48;
    --brand-btn: #0B8457;
    --brand-btn-hover: #0A6E48;
    --teal: #0E9F8E;
    --teal-btn: #0C8073;
    --teal-btn-hover: #0A6356;
    --amber: #F5A623;
    --amber-deep: #8A5300;
    --amber-btn: #CF8400;
    --grape: #6C5CE7;
    --grape-deep: #4B40C4;
    --sky: #2E90FA;
    --rose: #E5484D;

    /* Tile faces — white / black / green (the game's actual cipher tiles) */
    --tile-white-top: #FFFFFF;
    --tile-white-bot: #E9EFE7;
    --tile-white-edge: #C3D4C2;
    --tile-white-ink: #1E2A23;

    --tile-black-top: #3A423B;
    --tile-black-bot: #1A201B;
    --tile-black-edge: #0A0E0A;
    --tile-black-ink: #F3F8F0;

    --tile-green-top: #2FD792;
    --tile-green-bot: #0FA565;
    --tile-green-edge: #0A7B4B;
    --tile-green-ink: #053019;

    /* Hidden tile "shirt" — deep teal (nods to the box), distinct from the green 5 */
    --tile-hidden-bg: #0E6E60;
    --tile-hidden-edge: #094E44;
    --tile-hidden-ink: #E6FFF6;

    /* Shape */
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-xl: 28px;
    --r-pill: 999px;

    /* Soft, warm-tinted claymorphism shadows */
    --shadow-sm: 0 2px 6px rgba(20, 45, 33, .10);
    --shadow-md: 0 12px 26px rgba(20, 45, 33, .14);
    --shadow-lg: 0 24px 54px rgba(20, 45, 33, .18);
    --ring: 0 0 0 4px rgba(21, 182, 119, .32);

    --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
    --ease-out: cubic-bezier(.22, 1, .36, 1);

    --font-display: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

/* ---------- Reset / base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        radial-gradient(1100px 720px at 10% -10%, rgba(21, 182, 119, .20), transparent 58%),
        radial-gradient(950px 680px at 108% -4%, rgba(14, 159, 142, .16), transparent 55%),
        radial-gradient(900px 760px at 50% 118%, rgba(47, 215, 146, .16), transparent 60%);
    background-attachment: fixed;
    min-height: 100vh;
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: 1.15;
    font-weight: 600;
}

a {
    color: var(--brand-ink);
}

:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-radius: var(--r-sm);
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 20px 64px;
}

/* ---------- Brand ---------- */
.brand-link {
    text-decoration: none;
    color: inherit;
    display: inline-block;
}

.game-header h1,
.brand-link h1 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -.01em;
    font-size: clamp(2rem, 5vw, 3.1rem);
    color: var(--ink);
    line-height: 1.05;
}

.brand-link h1 .the-small,
.the-small {
    font-size: .52em;
    font-weight: 500;
    color: var(--brand-ink);
    vertical-align: middle;
}

/* ---------- Buttons ---------- */
.btn {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 14px 22px;
    border-radius: var(--r-pill);
    /* default (variant-less) appearance — e.g. "Copy ID" */
    background: var(--surface);
    color: var(--ink);
    border: 2px solid var(--line-strong);
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    transition: transform .14s var(--ease-bounce), box-shadow .18s var(--ease-out),
        background-color .18s var(--ease-out), filter .18s var(--ease-out);
    will-change: transform;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(1px) scale(.98);
}

.btn:disabled,
.btn[disabled] {
    cursor: not-allowed;
    opacity: .5;
    transform: none;
    filter: grayscale(.3);
    box-shadow: none;
}

.btn-icon {
    font-size: 1.1em;
    line-height: 1;
}

.btn-primary {
    background: var(--brand-btn);
    color: #fff;
    border-color: var(--brand-btn-hover);
    box-shadow: 0 6px 0 var(--brand-btn-hover), var(--shadow-md);
}

.btn-primary:hover {
    background: #0E9A66;
}

.btn-primary:active {
    box-shadow: 0 2px 0 var(--brand-btn-hover), var(--shadow-sm);
}

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-strong);
    box-shadow: 0 5px 0 var(--line-strong), var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--surface-2);
}

.btn-secondary:active {
    box-shadow: 0 2px 0 var(--line-strong);
}

.btn-success {
    background: var(--teal-btn);
    color: #fff;
    border-color: var(--teal-btn-hover);
    box-shadow: 0 6px 0 var(--teal-btn-hover), var(--shadow-md);
}

.btn-success:hover {
    background: #0E9485;
}

.btn-success:active {
    box-shadow: 0 2px 0 var(--teal-btn-hover);
}

.btn-warning {
    background: var(--amber-btn);
    color: #fff;
    border-color: #B45309;
    box-shadow: 0 6px 0 #B45309, var(--shadow-md);
}

.btn-warning:hover {
    background: #C77A00;
}

.btn-warning:active {
    box-shadow: 0 2px 0 #B45309;
}

.btn-small {
    min-height: 40px;
    padding: 10px 16px;
    font-size: .9rem;
    box-shadow: var(--shadow-sm) !important;
    border-bottom-width: 2px;
}

.btn-small:active {
    box-shadow: none !important;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .95rem;
    color: var(--ink);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
    border: 2px solid var(--line-strong);
    border-radius: var(--r-md);
    padding: 13px 16px;
    min-height: 50px;
    transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
    appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238B7C68' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 44px;
    cursor: pointer;
}

.form-group input::placeholder {
    color: var(--muted);
    font-weight: 500;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
}

.setup-helper,
.form-group small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.5;
}

/* ---------- Status toast ---------- */
.status-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-16px);
    z-index: 90;
    max-width: min(440px, calc(100% - 28px));
    padding: 14px 20px;
    border-radius: var(--r-md);
    font-weight: 700;
    font-size: .95rem;
    color: #fff;
    background: var(--ink);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s var(--ease-out), transform .25s var(--ease-bounce);
}

.status-message:not(:empty) {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.status-message.success {
    background: var(--teal-btn);
}

.status-message.error {
    background: var(--rose);
}

.status-message.info {
    background: var(--grape);
}

.status-message.warning {
    background: var(--amber-btn);
}

/* =====================================================================
   LANDING PAGE (index.html)
   ===================================================================== */
.setup-container {
    max-width: 1080px;
}

/* Hero */
.setup-page .game-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-xl);
    padding: 34px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-md);
    text-align: left;
}

.setup-hero-copy {
    max-width: 640px;
}

.hero-kicker,
.setup-panel-kicker {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .76rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--brand-ink);
    background: #D9F2E4;
    padding: 5px 12px;
    border-radius: var(--r-pill);
    margin-bottom: 14px;
}

.author {
    font-family: var(--font-display);
    color: var(--muted);
    font-weight: 500;
    margin: 8px 0 6px;
}

.tagline {
    color: var(--ink-2);
    font-size: 1.08rem;
    font-weight: 600;
    max-width: 52ch;
}

.setup-hero-notes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.setup-chip {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: .85rem;
    color: var(--ink);
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: var(--r-pill);
    padding: 8px 16px;
}

/* Tabs */
.setup-tabs {
    display: inline-flex;
    gap: 6px;
    padding: 6px;
    margin-bottom: 22px;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-sm);
}

.setup-tab {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .95rem;
    color: var(--ink-2);
    background: transparent;
    border: none;
    border-radius: var(--r-pill);
    padding: 10px 22px;
    min-height: 44px;
    cursor: pointer;
    transition: background-color .18s var(--ease-out), color .18s var(--ease-out);
}

.setup-tab:hover {
    color: var(--ink);
    background: var(--surface-sunken);
}

.setup-tab.is-active {
    color: #fff;
    background: var(--brand-btn);
    box-shadow: var(--shadow-sm);
}

/* Views */
.setup-view {
    display: none;
    animation: fade-rise .3s var(--ease-out);
}

.setup-view.is-active {
    display: block;
}

@keyframes fade-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.play-hub {
    display: grid;
    gap: 18px;
}

.setup-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.setup-toolbar-card {
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.setup-toolbar-card strong {
    display: block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.12rem;
    margin-bottom: 8px;
    color: var(--ink);
}

.setup-toolbar-card p {
    color: var(--ink-2);
    font-size: .96rem;
}

/* Play launcher */
.play-launcher {
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-xl);
    padding: 30px;
    box-shadow: var(--shadow-md);
}

.play-launcher-copy h2 {
    font-size: clamp(1.6rem, 3.4vw, 2.2rem);
    margin: 4px 0 8px;
}

.play-launcher-copy p {
    color: var(--ink-2);
    margin-bottom: 22px;
    font-weight: 600;
}

.play-mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.play-mode-card {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface-2);
    border: 2px solid var(--line-strong);
    border-radius: var(--r-lg);
    padding: 22px;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--line-strong);
    transition: transform .16s var(--ease-bounce), box-shadow .18s var(--ease-out),
        border-color .18s var(--ease-out), background-color .18s var(--ease-out);
}

.play-mode-card:hover {
    transform: translateY(-3px);
    border-color: var(--brand);
    box-shadow: 0 8px 0 var(--brand), var(--shadow-md);
    background: var(--surface);
}

.play-mode-card:active {
    transform: translateY(1px);
    box-shadow: 0 3px 0 var(--brand);
}

.play-mode-card:focus-visible {
    box-shadow: var(--ring), 0 5px 0 var(--brand);
}

.play-mode-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink);
}

.play-mode-text {
    color: var(--ink-2);
    font-size: .95rem;
    font-weight: 600;
}

/* Panels (Brief / Guide) */
.setup-panel {
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-xl);
    padding: 30px;
    box-shadow: var(--shadow-md);
}

.setup-panel h2 {
    font-size: clamp(1.5rem, 3.2vw, 2rem);
    margin: 4px 0 20px;
}

.setup-brief-list {
    display: grid;
    gap: 14px;
}

.brief-item {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 16px;
    align-items: baseline;
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px 18px;
}

.brief-item strong {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--brand-ink);
}

.brief-item span {
    color: var(--ink-2);
    font-weight: 600;
}

/* Details (Guide) */
.setup-details {
    border: 2px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    margin-bottom: 12px;
    overflow: hidden;
}

.setup-details summary {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--ink);
    padding: 16px 18px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.setup-details summary::-webkit-details-marker {
    display: none;
}

.setup-details summary::after {
    content: '+';
    font-size: 1.5rem;
    color: var(--brand-ink);
    transition: transform .2s var(--ease-out);
}

.setup-details[open] summary::after {
    transform: rotate(45deg);
}

.setup-details ul,
.setup-details p {
    padding: 0 18px;
    color: var(--ink-2);
    font-weight: 600;
}

.setup-details ul {
    list-style: none;
    padding-bottom: 12px;
}

.setup-details li {
    padding: 6px 0 6px 22px;
    position: relative;
}

.setup-details li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
}

.setup-details p {
    padding-bottom: 12px;
}

.setup-details .btn {
    margin: 4px 18px 18px;
}

/* Modal */
.setup-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(51, 40, 27, .5);
    backdrop-filter: blur(6px);
    animation: fade-rise .25s var(--ease-out);
}

.setup-modal {
    width: min(480px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-xl);
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

.setup-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.setup-modal-header h2 {
    font-size: 1.7rem;
}

.modal-close-btn {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color .18s var(--ease-out), color .18s var(--ease-out), transform .14s var(--ease-bounce);
}

.modal-close-btn:hover {
    background: var(--rose);
    color: #fff;
    border-color: var(--rose);
    transform: rotate(90deg);
}

.action-panel {
    display: none;
}

.action-panel.is-active {
    display: block;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Landing responsive ---------- */
@media (max-width: 680px) {
    .container {
        padding: 18px 14px 56px;
    }

    .setup-page .game-header {
        padding: 24px 20px;
        flex-direction: column;
        align-items: flex-start;
    }

    .setup-tabs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
    }

    .setup-tab {
        padding: 10px 8px;
    }

    .play-launcher,
    .setup-panel {
        padding: 22px 18px;
    }

    .brief-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .setup-modal {
        padding: 22px 18px;
    }
}
