/* ==========================================================================
   SIMON SAYS — Embedded Game Interface
   Design System & UX/UI matching chaddytwiceover.com
   ========================================================================== */

:root {
    /* Base Color Tokens */
    --bg: #0a0a0a;
    --bg-soft: rgba(20, 20, 20, 0.7);
    --bg-card: rgba(24, 24, 24, 0.55);
    --border: rgba(255, 255, 255, 0.09);
    --border-hover: rgba(255, 255, 255, 0.22);
    --text: #edebe6;
    --text-dim: #9a9a95;
    --text-faint: #8a8a84;

    /* Theme Neon Accents */
    --color-mint: #7affd2;
    --color-lime: #d6ff5c;
    --color-coral: #ff6b6b;
    --color-amber: #ffb86b;

    /* Simon Pad Colors */
    --pad-green: #d6ff5c;
    --pad-green-glow: rgba(214, 255, 92, 0.65);
    --pad-red: #ff6b6b;
    --pad-red-glow: rgba(255, 107, 107, 0.65);
    --pad-yellow: #ffb86b;
    --pad-yellow-glow: rgba(255, 184, 107, 0.65);
    --pad-blue: #7affd2;
    --pad-blue-glow: rgba(122, 255, 210, 0.65);

    /* Typography */
    --font-serif: ui-serif, Georgia, Cambria, 'Times New Roman', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Animation & Transitions */
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --transition-fast: 0.15s var(--ease-out);
    --transition-base: 0.2s var(--ease-out);
}

/* Reset & Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

::selection {
    background: #edebe6;
    color: #0a0a0a;
}

html {
    background-color: var(--bg);
    color-scheme: dark;
    height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background Texture: Dot Grid Pattern from chaddytwiceover.com */
body::before {
    content: "";
    pointer-events: none;
    opacity: 0.035;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='%23ffffff' fill-opacity='0.9'%3E%3Ccircle cx='8' cy='12' r='1'/%3E%3Ccircle cx='37' cy='84' r='1'/%3E%3Ccircle cx='66' cy='24' r='1'/%3E%3Ccircle cx='98' cy='58' r='1'/%3E%3Ccircle cx='26' cy='42' r='1'/%3E%3Ccircle cx='114' cy='94' r='1'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 120px 120px;
    position: fixed;
    inset: 0;
}

/* ==========================================================================
   GAME WRAPPER & CARD
   ========================================================================== */
.game-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    height: 100%;
    max-height: 960px;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    margin: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-card {
    width: 100%;
    height: 100%;
    min-height: 0;
    background-color: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.75rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: none;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
    gap: clamp(6px, 1.6dvh, 20px);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.game-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   HUD & METRICS
   ========================================================================== */
.hud-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.metric-card {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.metric-label {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    margin-bottom: 2px;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

/* ==========================================================================
   CONTROLS: State, Difficulty, Sound
   ========================================================================== */
.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

/* State Badge */
.state-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.35);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    transition: all var(--transition-fast);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-faint);
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.state-idle .status-dot {
    background-color: var(--text-faint);
}

.state-watching .status-dot {
    background-color: var(--color-amber);
    box-shadow: 0 0 8px var(--color-amber);
}

.state-playing .status-dot {
    background-color: var(--color-mint);
    box-shadow: 0 0 8px var(--color-mint);
}

.state-game-over .status-dot {
    background-color: var(--color-coral);
    box-shadow: 0 0 8px var(--color-coral);
}

/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.35);
    padding: 2.5px;
    border-radius: 9999px;
    border: 1px solid var(--border);
}

.diff-btn {
    min-height: 40px;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.diff-btn:hover:not(:disabled) {
    color: var(--text);
}

.diff-btn.active {
    background-color: var(--text);
    color: var(--bg);
    font-weight: 700;
}

.diff-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Sound Button */
.icon-btn {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-dim);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.sound-icon {
    width: 15px;
    height: 15px;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   SIMON SAYS BOARD
   ========================================================================== */
.board-wrapper {
    min-width: 0;
    min-height: 0;
    container-type: size;
    display: grid;
    place-items: center;
}

.game-board {
    position: relative;
    width: min(100cqw, 100cqh, 360px);
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
    padding: 12px;
    background: #111111;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 32px;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.9), 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* Color Pads */
.color-pad {
    appearance: none;
    -webkit-appearance: none;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    outline-offset: 4px;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    min-height: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    filter: brightness(0.65);
    transition: filter 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    will-change: filter, transform, box-shadow;
}

.pad-green {
    border-top-left-radius: 22px;
    background: radial-gradient(circle at 35% 35%, rgba(214, 255, 92, 0.45) 0%, rgba(18, 22, 14, 0.95) 75%);
    border-color: rgba(214, 255, 92, 0.25);
}

.pad-red {
    border-top-right-radius: 22px;
    background: radial-gradient(circle at 65% 35%, rgba(255, 107, 107, 0.45) 0%, rgba(24, 15, 15, 0.95) 75%);
    border-color: rgba(255, 107, 107, 0.25);
}

.pad-yellow {
    border-bottom-left-radius: 22px;
    background: radial-gradient(circle at 35% 65%, rgba(255, 184, 107, 0.45) 0%, rgba(24, 20, 14, 0.95) 75%);
    border-color: rgba(255, 184, 107, 0.25);
}

.pad-blue {
    border-bottom-right-radius: 22px;
    background: radial-gradient(circle at 65% 65%, rgba(122, 255, 210, 0.45) 0%, rgba(14, 22, 20, 0.95) 75%);
    border-color: rgba(122, 255, 210, 0.25);
}

.color-pad:not(:disabled):hover {
    filter: brightness(0.85);
    border-color: rgba(255, 255, 255, 0.3);
}

.color-pad:disabled {
    cursor: not-allowed;
}

/* Active Luminescence */
.pad-green.active {
    background: var(--pad-green) !important;
    filter: brightness(1.25) !important;
    border-color: #ffffff !important;
    transform: scale(0.975);
    box-shadow: 0 0 34px var(--pad-green-glow), inset 0 0 14px rgba(255, 255, 255, 0.8);
}

.pad-red.active {
    background: var(--pad-red) !important;
    filter: brightness(1.25) !important;
    border-color: #ffffff !important;
    transform: scale(0.975);
    box-shadow: 0 0 34px var(--pad-red-glow), inset 0 0 14px rgba(255, 255, 255, 0.8);
}

.pad-yellow.active {
    background: var(--pad-yellow) !important;
    filter: brightness(1.25) !important;
    border-color: #ffffff !important;
    transform: scale(0.975);
    box-shadow: 0 0 34px var(--pad-yellow-glow), inset 0 0 14px rgba(255, 255, 255, 0.8);
}

.pad-blue.active {
    background: var(--pad-blue) !important;
    filter: brightness(1.25) !important;
    border-color: #ffffff !important;
    transform: scale(0.975);
    box-shadow: 0 0 34px var(--pad-blue-glow), inset 0 0 14px rgba(255, 255, 255, 0.8);
}

/* Center Hub */
.board-hub {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22%;
    height: 22%;
    border-radius: 50%;
    background-color: #0d0d0d;
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.85);
    pointer-events: none;
    z-index: 5;
}

.hub-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--text-dim);
}

/* ==========================================================================
   PROMPTS & BUTTONS
   ========================================================================== */
.game-message {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    text-align: center;
    min-height: 18px;
    transition: color var(--transition-fast);
}

.start-btn {
    appearance: none;
    border: none;
    width: 100%;
    min-height: 46px;
    border-radius: 9999px;
    background-color: var(--text);
    color: var(--bg);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.start-btn:hover {
    background-color: var(--color-mint);
    color: #000;
    transform: translateY(-1px);
    box-shadow: 0 0 22px rgba(122, 255, 210, 0.35);
}

.start-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   RESPONSIVE DESIGN & ACCESSIBILITY
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .color-pad,
    .start-btn,
    .diff-btn,
    .icon-btn {
        transition: none !important;
    }
}

/* Editorial typography and quiet framing shared with the parent site. */
.game-heading { padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.heading-meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--text-dim); font: 10px/1.5 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; }
.experiment-type { color: var(--color-mint); }
.game-heading h1 { margin: 1.25rem 0 .8rem; font: 400 clamp(2.75rem, 11vw, 4.25rem)/.95 var(--font-serif); letter-spacing: -.035em; }
.game-heading h1 span { color: var(--color-mint); }
.game-heading p { color: var(--text-dim); font-size: 14px; line-height: 1.7; }
.game-footnote { color: var(--text-faint); font: 10px/1.6 var(--font-mono); text-align: center; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; }
.color-pad:focus-visible { outline: 2px solid var(--text); outline-offset: -5px; }
/* Fit the available viewport (including an iframe), reserving space for controls. */
.game-card > * { min-width: 0; }
.metric-card { min-width: 0; }
.metric-value { font-size: clamp(12px, 3.6vw, 17.6px); overflow-wrap: anywhere; }
.game-message { min-height: 3em; display: grid; place-items: center; }
.game-heading h1 { font-size: clamp(32px, 7dvh, 68px); }
.controls-row { flex-wrap: wrap; }
.board-hub .hub-label { font-size: clamp(6px, 3cqw, 11px); }

@media (max-height: 800px), (max-width: 440px) {
    .game-card { padding: 12px; gap: 8px; }
    .game-heading { padding-bottom: 10px; }
    .game-heading h1 { margin: 10px 0 8px; }
    .game-heading p { font-size: 12px; }
    .heading-meta { font-size: 9px; gap: 6px; }
    .hud-panel { gap: 4px; }
    .metric-card { padding: 5px 2px; }
    .metric-label { font-size: 9px; letter-spacing: 0; }
    .controls-row { gap: 4px; }
    .state-pill { padding-inline: 6px; font-size: 9px; letter-spacing: 0; }
    .diff-btn { padding-inline: 6px; letter-spacing: 0; }
    .game-board { padding: 6px; gap: 6px; border-radius: 22px; }
}

@media (max-height: 650px) {
    .game-heading p, .game-footnote { display: none; }
    .game-card { grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; }
    .game-heading h1 { margin-bottom: 0; }
}

/* Short, wide screens put the board beside the controls instead of below them. */
@media (min-aspect-ratio: 6/5) and (max-height: 650px) {
    .game-wrapper { max-width: 920px; }
    .game-card {
        grid-template-columns: minmax(0, 1fr) minmax(260px, .9fr);
        grid-template-rows: auto auto auto minmax(0, 1fr) auto;
        column-gap: 20px;
    }
    .board-wrapper { grid-column: 1; grid-row: 1 / -1; }
    .game-heading, .hud-panel, .controls-row, .game-message, .action-row { grid-column: 2; }
    .game-heading { grid-row: 1; }
    .hud-panel { grid-row: 2; }
    .controls-row { grid-row: 3; }
    .game-message { grid-row: 4; }
    .action-row { grid-row: 5; }
    .game-heading h1 { font-size: clamp(28px, 9dvh, 48px); }
}

@media (max-height: 400px) {
    .game-card { padding: 6px; gap: 4px; }
    .heading-meta { display: none; }
    .game-heading { padding-bottom: 4px; }
    .game-heading h1 { font-size: 28px; margin: 0; }
    .game-message { font-size: 9px; }
    .metric-card { padding-block: 2px; }
}
