:root {
    --bg-color: #3d405b;
    --text-color: #f4f1de;
    --accent-color: #e07a5f;
    --board-border: #81b29a;
    --radius: 16px;
    --border-thick: 3px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

#root {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-wrapper {
    width: 100%;
    max-width: 460px;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* Header & Titles */
.game-title {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-color);
    text-transform: uppercase;
}

.game-title span {
    color: var(--accent-color);
}

.screen-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-color);
}

/* Common Layout Containers */
.menu-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
}

.content-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-color);
    background-color: transparent;
    border: var(--border-thick) solid var(--text-color);
    border-radius: var(--radius);
    box-shadow: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    user-select: none;
}

.btn:hover,
.btn:active,
.btn:focus-visible {
    background-color: var(--text-color);
    color: var(--bg-color);
    outline: none;
}

.btn-accent {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.btn-accent:hover,
.btn-accent:active,
.btn-accent:focus-visible {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.85rem;
    width: auto;
}

/* Inputs */
.input-text {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
    background-color: transparent;
    border: var(--border-thick) solid var(--text-color);
    border-radius: var(--radius);
    box-shadow: none;
    outline: none;
    text-align: center;
    text-transform: uppercase;
    transition: border-color 0.2s ease;
}

.input-text:focus {
    border-color: var(--accent-color);
}

.input-text::placeholder {
    color: rgba(244, 241, 222, 0.45);
    text-transform: none;
}

/* Cards */
.player-card {
    background-color: rgba(244, 241, 222, 0.07);
    border: 2px solid rgba(244, 241, 222, 0.25);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.player-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.player-stats {
    display: flex;
    gap: 16px;
    font-size: 0.95rem;
    color: rgba(244, 241, 222, 0.8);
}

.player-stat-val {
    font-weight: 800;
    color: var(--text-color);
}

/* Status Labels & Messages */
.status-banner {
    text-align: center;
    padding: 14px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-color);
    border-radius: var(--radius);
}

.countdown-label {
    font-size: 1.5rem;
    color: var(--accent-color);
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}

.error-message {
    color: var(--accent-color);
    font-weight: 700;
    text-align: center;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Share Link Box */
.link-box {
    display: flex;
    gap: 8px;
    align-items: center;
    background-color: rgba(244, 241, 222, 0.05);
    border: 2px dashed var(--board-border);
    border-radius: var(--radius);
    padding: 10px 14px;
    width: 100%;
}

.link-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.9;
}

/* Game Screen */
.game-screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
}

.color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid rgba(0, 0, 0, 0.2);
}

.turn-indicator {
    font-size: 1.1rem;
    font-weight: 800;
    text-align: center;
    padding: 6px 14px;
    border-radius: var(--radius);
    border: 2px solid var(--board-border);
    color: var(--text-color);
}

.turn-indicator.active-turn {
    background-color: var(--text-color);
    color: var(--bg-color);
    border-color: var(--text-color);
}

/* Game Canvas Container */
#game-container {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius);
    overflow: hidden;
    user-select: none;
}

#game-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    border-radius: var(--radius);
}

/* Game Result Banner */
.result-banner {
    font-size: 2rem;
    font-weight: 900;
    text-transform: uppercase;
    text-align: center;
    padding: 12px 24px;
    border-radius: var(--radius);
    margin-top: 8px;
    letter-spacing: 1px;
}

.result-banner.win {
    background-color: var(--board-border);
    color: var(--bg-color);
}

.result-banner.lose {
    background-color: var(--accent-color);
    color: var(--text-color);
}

/* Modal Overlay (for Settings / Edit Name) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(61, 64, 91, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 100;
}

.modal-content {
    background-color: var(--bg-color);
    border: var(--border-thick) solid var(--text-color);
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}