/* Quiet cream design values; each application owns its styles and release. */
:root {
    --page: #fff8ed;
    --ink: #17334c;
    --brand: #b94032;
    --accent: #9c392e;
    --line: #e7dfd2;
    --secondary: #4a5661;
    --muted: #616d75;
    --soft: #fbf8f2;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--page);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    color: var(--ink);
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-width: 488px;
    margin: 0 auto;
    padding: 18px 14px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding-inline: 40px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

h1 {
    color: var(--brand);
    font-size: 30px;
    font-weight: 800;
    margin-bottom: 6px;
    text-shadow: none;
}

h2 {
    color: var(--ink);
    font-size: 16px;
    font-weight: 400;
    opacity: 0.95;
    text-shadow: none;
}

header .parent-site {
    display: block;
    width: fit-content;
    margin: 0 auto;
    padding: 7px 0;
    color: var(--ink);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    text-decoration: none;
    text-shadow: none;
}
header .parent-site:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Game Info Pills */
.game-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    color: var(--secondary);
    font-size: 14px;
    font-weight: 600;
    margin-top: 8px;
}

.game-info span {
    background: #f8f4ed;
    padding: 4px 12px;
    border-radius: 16px;
}

/* Main Content Card */
.game-content {
    background: white;
    border-radius: 22px;
    border: 1px solid var(--line);
    padding: 20px;
    box-shadow: 0 4px 16px #17334c06;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Buttons */
.btn {
    min-height: 44px;
    min-width: 0;
    flex-shrink: 0;
    overflow-wrap: anywhere;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-transform: none;
    letter-spacing: 0;
    width: 100%;
}

.btn-primary {
    background: var(--ink);
    color: white;
}

.btn-primary:hover {
    background: #254a67;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--soft);
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn-secondary:hover {
    background: #f0f0f0;
}

.btn-secondary:active {
    transform: scale(0.98);
}

/* Actions Container */
.actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    margin-top: auto;
}

.actions .btn {
    flex: 1;
}

/* Lists */
.player-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin-bottom: 16px;
}

.player-item {
    padding: 12px 16px;
    background: var(--soft);
    border-radius: 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-item:last-child {
    margin-bottom: 0;
}

.player-name {
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 500;
    color: var(--ink);
}

.player-status {
    font-size: 12px;
    color: var(--muted);
}

.status-ready {
    color: #4CAF50;
}

.status-waiting {
    color: #FF9800;
}

/* Status Messages */
.status-message {
    text-align: center;
    padding: 16px;
    background: #FFF3E0;
    border-radius: 10px;
    color: #F57C00;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}

/* Instructions */
.instructions {
    color: var(--secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.instructions strong {
    color: var(--ink);
    font-weight: 600;
}

/* Game Code Display */
.game-code-display {
    text-align: center;
    padding: 20px;
    background: var(--ink);
    border-radius: 12px;
    color: white;
    margin-bottom: 20px;
}

.game-code-label {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.game-code {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 4px;
}

.comparison-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.comparison-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 8px;
    text-align: center;
    padding: 8px;
    background: var(--soft);
    border-radius: 8px;
}

.comparison-list {
    flex: 1;
    overflow-y: auto;
    background: #fafafa;
    border-radius: 8px;
    padding: 8px;
}

.comparison-item {
    padding: 8px 10px;
    background: white;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.comparison-item:last-child {
    margin-bottom: 0;
}

.comparison-item-number {
    width: 20px;
    height: 20px;
    background: var(--ink);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    margin-right: 10px;
    flex-shrink: 0;
}

/* Hamburger Menu */
.hamburger-menu {
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 1000;
}

.menu-toggle {
    width: 44px;
    height: 44px;
    background: #ffffffcc;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    transition: background-color 0.3s ease;
}

.menu-toggle:hover {
    background: white;
}

.menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--ink);
    border-radius: 1px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(3px, 3px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(3px, -3px);
}

.menu-dropdown {
    position: absolute;
    top: 52px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    max-height: calc(100dvh - 68px);
    overflow-y: auto;
}

.menu-toggle.active + .menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    border-bottom: 1px solid #f0f0f0;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item a {
    min-height: 44px;
    display: block;
    padding: 14px 18px;
    color: var(--ink);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.menu-item a:hover {
    background: var(--soft);
    color: var(--ink);
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: transparent;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Responsive Design */
@media (max-height: 600px) {
    .container { padding: 8px; }
    h1 { font-size: 24px; margin-bottom: 4px; }
    h2 { font-size: 14px; }
    .game-info { font-size: 12px; }
    .game-content { padding: 16px; }
    .instructions { font-size: 13px; margin-bottom: 12px; }
    .btn { padding: 12px; font-size: 13px; }
    .game-code { font-size: 28px; }
}

@media (max-height: 500px) {
    .game-content { padding: 12px; }
    .player-item { padding: 10px 12px; }
    .actions { gap: 8px; }
    .btn { padding: 10px; }
}

/* Shared overlay geometry; each page owns its appearance and visibility. */
.overlay, .alignment-info-overlay, .modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.winner-popup, .alignment-info-popup, .modal {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overflow-wrap: anywhere;
}
.alignment-info-overlay[hidden] {
    display: none;
}
.btn-primary:disabled, .btn-primary.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
button:focus-visible, a:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.account-attachment { max-width: 420px; width: calc(100% - 32px); border: 0; border-radius: 16px; padding: 24px; color: inherit; }
.account-attachment::backdrop { background: #0007; }
.account-attachment .btn { width: 100%; margin-top: 10px; }
.account-attachment p { line-height: 1.5; }


.account-notice { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 10000; width: max-content; max-width: calc(100vw - 24px); box-sizing: border-box; margin: 0; padding: 12px 18px; border-radius: 12px; background: #17334c; color: white; box-shadow: 0 4px 18px #0003; font: 16px/1.4 system-ui, sans-serif; text-align: center; }
.account-notice button { display: block; margin: 8px auto 0; padding: 8px 16px; border: 0; border-radius: 8px; background: white; color: #17334c; font: inherit; cursor: pointer; }

:focus-visible { outline: 3px solid #16777d; outline-offset: 3px; }
dialog { border-radius: 22px; color: var(--ink); }
dialog::backdrop { background: #17334c66; }
