/* ========================================
   Sternhalma – CSS Styles
   Retro Glass Marble Style
   ======================================== */

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

body {
    font-family: 'Outfit', sans-serif;
    background: url('../img/bg.png') center center / cover no-repeat fixed;
    min-height: 100vh;
    overflow: auto;
    color: #333;
    overscroll-behavior: none;
}

/* ---- Screens ---- */
.screen {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
}
.screen.visible {
    display: flex;
}
.overlay {
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

/* ---- Title Logo ---- */
.title-logo {
    display: block;
    max-width: 380px;
    margin: 0 auto 5px;
}
.lang-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 4px;
}
.lang-btn {
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border: 2px solid #d0dce8;
    border-radius: 8px;
    background: transparent;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
}
.lang-btn.active {
    background: #0074D9;
    border-color: #0074D9;
    color: #fff;
}
.lang-btn:hover:not(.active) {
    border-color: #0074D9;
    color: #0074D9;
}
.setup-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}
.setup-help-link {
    display: inline-block;
    color: #5a7da8;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    padding: 8px 24px;
    border: 2px solid #d0dce8;
    border-radius: 20px;
    transition: all 0.2s ease;
}
.setup-help-link:hover {
    background: #edf2f7;
    border-color: #0074D9;
    color: #0074D9;
}

/* ---- Buttons ---- */
.btn {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.btn:active {
    transform: translateY(0);
}
.btn-primary {
    background: linear-gradient(135deg, #2ECC40, #27AE60);
    color: #fff;
    font-size: 1.15rem;
    padding: 14px 36px;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #27AE60, #219A52);
}
.btn-secondary {
    background: linear-gradient(135deg, #bdc3c7, #95a5a6);
    color: #fff;
}
.btn-secondary:hover {
    background: linear-gradient(135deg, #a0a8ab, #7f8c8d);
}
.btn-accent {
    background: linear-gradient(135deg, #FF851B, #e67e22);
    color: #fff;
    font-size: 1.05rem;
    padding: 12px 28px;
    animation: pulse-btn 2s infinite;
}
@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,133,27,0.4); }
    50% { box-shadow: 0 0 0 10px rgba(255,133,27,0); }
}

/* ---- Online Button ---- */
.btn-online {
    display: block;
    width: 100%;
    margin-top: 10px;
    background: linear-gradient(135deg, #0074D9, #0056b3);
    color: #fff;
    font-size: 1.05rem;
    padding: 12px 28px;
}
.btn-online:hover {
    background: linear-gradient(135deg, #0056b3, #004494);
}

/* ---- Lobby Screen ---- */
#lobby-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f0f4f8, #dfe6ed);
}
.lobby-container { text-align: left; }
.lobby-title {
    text-align: center;
    font-size: 1.4rem;
    color: #2c3e50;
    margin-bottom: 8px;
}
.connection-status {
    text-align: center;
    font-size: 0.85rem;
    color: #27AE60;
    margin-bottom: 16px;
}
.lobby-section {
    margin-top: 16px;
}
.lobby-buttons {
    display: flex;
    gap: 8px;
}
.lobby-buttons .btn {
    flex: 1;
    font-size: 0.9rem;
    padding: 10px 12px;
}
.player-name-display {
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
    padding: 8px 14px;
    background: #f0f4f8;
    border-radius: 10px;
    text-align: center;
}
.room-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #dfe6ed;
    border-radius: 10px;
    padding: 8px;
}
.no-games {
    text-align: center;
    color: #999;
    font-size: 0.85rem;
    padding: 12px;
}
.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f8fafc;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.room-item:hover { background: #edf2f7; }
.room-item-name { font-weight: 600; color: #2c3e50; }
.room-item-join {
    font-size: 0.8rem;
    font-weight: 700;
    color: #0074D9;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #dfe6ed;
    border-top-color: #0074D9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 12px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.code-hint {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 12px 0 8px;
}
.invite-link-row {
    display: flex;
    gap: 8px;
}
.invite-link-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #dfe6ed;
    border-radius: 10px;
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    background: #f8fafc;
    color: #2c3e50;
}
.copy-invite-btn {
    white-space: nowrap;
}
#lobby-back-btn {
    display: block;
    width: 100%;
    margin-top: 20px;
}

/* ========================================
   SETUP SCREEN
   ======================================== */
#setup-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f0f4f8, #dfe6ed);
}
.setup-container {
    position: relative;
    background: #fff;
    border-radius: 24px;
    padding: 40px 48px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    max-width: 460px;
    width: 90%;
    text-align: center;
    box-sizing: border-box;
    overflow: hidden;
}
.setup-title {
    font-size: 2.4rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 4px;
}
.setup-subtitle {
    font-size: 1rem;
    color: #7f8c8d;
    margin-bottom: 32px;
    font-weight: 300;
}
.setup-section {
    margin-bottom: 24px;
    text-align: left;
}
.setup-label {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7f8c8d;
    display: block;
    margin-bottom: 10px;
}

/* Player count buttons */
.player-count-group,
.difficulty-group {
    display: flex;
    gap: 8px;
}
.player-count-btn,
.difficulty-btn {
    flex: 1;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 10px 0;
    border: 2px solid #dfe6ed;
    border-radius: 10px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}
.player-count-btn:hover,
.difficulty-btn:hover {
    border-color: #3498db;
    color: #3498db;
}
.player-count-btn.active,
.difficulty-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}

/* Player name fields */
.player-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.player-color-icon {
    flex-shrink: 0;
    border-radius: 50%;
}
.player-name-input {
    flex: 1;
    min-width: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    padding: 10px 14px;
    border: 2px solid #e0e5ea;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.player-name-input:focus {
    border-color: #3498db;
}

/* Player type toggle */
.player-type-btn {
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 6px 10px;
    border: 2px solid #dfe6ed;
    border-radius: 8px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 36px;
    text-align: center;
}
.player-type-btn.is-ai {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}
.player-type-btn.is-human {
    background: #2ECC40;
    border-color: #2ECC40;
    color: #fff;
}

#start-btn {
    width: 100%;
    margin-top: 10px;
}

/* ========================================
   GAME SCREEN
   ======================================== */
#game-screen {
    background: linear-gradient(135deg, #f0f4f8, #dfe6ed);
}
.game-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Top bar */
.game-topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    position: relative;
    z-index: 10;
}
.turn-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}
.turn-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #999;
}
.turn-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 22px;
    border-radius: 20px;
    color: #fff;
    font-weight: 600;
    font-size: 1.05rem;
    transition: background 0.3s;
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}
.turn-badge canvas {
    border-radius: 50%;
}
.topbar-buttons {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
}
.btn-small {
    font-size: 0.95rem;
    padding: 10px 20px;
    border-radius: 10px;
}

/* Board container */
.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 16px;
    min-height: 0;
}
#game-canvas {
    cursor: pointer;
    border-radius: 16px;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Bottom bar */
.game-bottombar {
    display: flex;
    justify-content: center;
    padding: 8px 20px 16px;
    min-height: 56px;
}

/* ========================================
   WIN SCREEN
   ======================================== */
.win-container {
    background: #fff;
    border-radius: 24px;
    padding: 40px 48px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 90%;
    text-align: center;
}
.win-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: #2c3e50;
}
.win-ranking {
    margin-bottom: 24px;
}
.ranking-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 6px;
    background: #f7f9fb;
}
.ranking-entry:first-child {
    background: linear-gradient(135deg, #fff9e6, #fff3cc);
    box-shadow: 0 2px 8px rgba(255,200,0,0.15);
}
.rank-medal {
    font-size: 1.5rem;
}
.rank-name {
    flex: 1;
    font-weight: 600;
    text-align: left;
}
.rank-moves {
    font-size: 0.85rem;
    color: #999;
}

/* ========================================
   HELP OVERLAY
   ======================================== */
.help-container {
    background: #fff;
    border-radius: 24px;
    padding: 36px 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.help-container h2 {
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: #2c3e50;
}
.help-container h3 {
    font-size: 1.05rem;
    margin: 16px 0 8px;
    color: #2c3e50;
}
.help-content p {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 8px;
}
.help-content ul {
    list-style: none;
    padding: 0;
}
.help-content li {
    font-size: 0.9rem;
    color: #555;
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
    line-height: 1.5;
}
.help-content li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: #3498db;
    font-weight: bold;
}
.help-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
}
.help-dot.blue {
    background: rgba(0, 116, 217, 0.5);
}
.help-dot.green {
    background: rgba(46, 204, 64, 0.5);
}

/* Confirm dialog */
.confirm-container {
    background: #fff;
    border-radius: 20px;
    padding: 30px 35px;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.confirm-container h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #2c3e50;
}
.confirm-container p {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 24px;
}
.confirm-buttons {
    display: flex;
    gap: 10px;
}
.confirm-buttons .btn {
    flex: 1;
    font-size: 0.95rem;
}
.help-container .btn {
    margin-top: 16px;
    width: 100%;
}

/* Settings overlay */
.settings-container {
    background: #fff;
    border-radius: 20px;
    padding: 30px 35px;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.settings-container h2 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #2c3e50;
}
.settings-options {
    margin-bottom: 20px;
}
.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
    font-size: 0.95rem;
    color: #444;
    position: relative;
}
.settings-option input[type="checkbox"] {
    display: none;
}
.toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    transition: background 0.3s;
    flex-shrink: 0;
    margin-left: 12px;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.settings-option input:checked + .toggle-slider {
    background: #0074D9;
}
.settings-option input:checked + .toggle-slider::after {
    transform: translateX(22px);
}
.settings-container .btn {
    width: 100%;
}

/* Stats overlay */
.stats-container {
    background: #fff;
    border-radius: 20px;
    padding: 30px 35px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.stats-container h2 {
    font-size: 1.4rem;
    margin-bottom: 16px;
    color: #2c3e50;
}
.stats-content {
    text-align: left;
    margin-bottom: 20px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
}
.stat-row:last-child {
    border-bottom: none;
}
.stat-label {
    color: #666;
}
.stat-value {
    font-weight: 600;
    color: #2c3e50;
}
.stats-buttons {
    display: flex;
    gap: 10px;
}
.stats-buttons .btn {
    flex: 1;
}
.stats-hint {
    font-size: 0.75rem;
    color: #999;
    font-style: italic;
    margin-top: 12px;
    line-height: 1.4;
}

/* Turn order dots */
.turn-order {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 6px;
}
.turn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: #fff;
    opacity: 0.45;
    transition: all 0.3s ease;
}
.turn-dot.active {
    width: 16px;
    height: 16px;
    opacity: 1;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.5), 0 0 8px rgba(0,0,0,0.2);
}
.turn-dot.finished {
    opacity: 0.3;
    font-size: 9px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 700px) {
    .game-topbar {
        flex-direction: column;
        gap: 8px;
        padding: 10px 12px;
    }
    .topbar-buttons {
        position: static;
        transform: none;
    }
    .board-container {
        padding: 4px 8px;
    }
    .btn {
        min-height: 44px;
        font-size: 0.95rem;
    }
    .btn-small {
        min-height: 40px;
        padding: 8px 16px;
    }
    .player-count-btn,
    .difficulty-btn {
        min-width: 44px;
        min-height: 44px;
    }
    .player-type-btn {
        min-width: 40px;
        min-height: 40px;
    }
    .setup-container {
        padding: 28px 20px;
    }
    .settings-option {
        padding: 14px 0;
    }
    .toggle-slider {
        width: 52px;
        height: 28px;
    }
}

/* Compact layout for iframe embedding (max 700px height) */
@media (max-height: 700px) {
    .setup-container {
        padding: 24px 32px;
    }
    .title-logo {
        max-width: 260px;
        margin-bottom: 2px;
    }
    .setup-section {
        margin-bottom: 10px;
    }
    .setup-label {
        margin-bottom: 6px;
        font-size: 0.8rem;
    }
    .setup-help-link {
        margin-top: 14px;
    }
    .game-topbar {
        padding: 6px 16px;
    }
    .btn-small {
        font-size: 0.85rem;
        padding: 7px 14px;
    }
    .board-container {
        padding: 0 8px;
    }
}

/* Playit-Online Logo */
.playit-logo-link {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.playit-logo-link:hover {
    opacity: 1;
}
.playit-logo {
    height: 50px;
    width: auto;
    display: block;
}

/* Build Version */
.build-version {
    position: fixed;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    z-index: 100;
    pointer-events: none;
    font-family: monospace;
}
