/* ===================================
   Okey Yazboz - Premium Mobile Design
   =================================== */

:root {
    /* Dark Theme (Default) */
    --bg-primary: #0d0d1a;
    --bg-secondary: #151528;
    --bg-card: #1a1a30;
    --bg-elevated: #222244;
    --bg-input: #252545;

    --text-primary: #ffffff;
    --text-secondary: #9999bb;
    --text-muted: #666688;

    --accent: #7c5cff;
    --accent-light: #9d85ff;
    --accent-glow: rgba(124, 92, 255, 0.4);

    --success: #00d9a0;
    --success-glow: rgba(0, 217, 160, 0.3);
    --warning: #ffb800;
    --warning-bg: rgba(255, 184, 0, 0.15);
    --danger: #ff4466;
    --danger-bg: rgba(255, 68, 102, 0.15);

    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50px;
}

[data-theme="light"] {
    --bg-primary: #f0f0f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f8f8fc;
    --bg-input: #eeeef5;

    --text-primary: #1a1a30;
    --text-secondary: #555566;
    --text-muted: #999999;

    --border: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.12);
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.app {
    min-height: 100vh;
    min-height: 100dvh;
}

.hidden {
    display: none !important;
}

/* ===================================
   Setup Screen
   =================================== */
.screen {
    min-height: 100vh;
    min-height: 100dvh;
}

#setup-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.setup-container {
    width: 100%;
    max-width: 360px;
}

.setup-logo {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.setup-logo h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.setup-logo p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.player-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem;
    transition: all 0.2s;
}

.player-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.player-number {
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.player-input input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    outline: none;
}

.player-input input::placeholder {
    color: var(--text-muted);
}

.btn-start {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent), #5a3fd9);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 4px 20px var(--accent-glow);
}

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

.btn-start .arrow {
    font-size: 1.25rem;
}

/* ===================================
   Game Screen
   =================================== */
#game-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-primary);
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-small {
    font-size: 1.25rem;
}

.app-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-light);
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 38px;
    height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-sun, .icon-moon {
    position: absolute;
    transition: all 0.3s;
}

.icon-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.icon-moon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

[data-theme="light"] .icon-sun {
    opacity: 1;
    transform: rotate(0) scale(1);
}

[data-theme="light"] .icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    flex-shrink: 0;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-el {
    background: var(--success);
    color: #000;
    box-shadow: 0 4px 15px var(--success-glow);
}

.btn-ceza {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 15px var(--danger-bg);
}

.btn-dice {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.action-icon {
    font-size: 1.1rem;
}

/* Ceza Section */
.ceza-section {
    margin: 0 0.75rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--warning);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.ceza-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--warning-bg);
}

.ceza-section-icon {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--warning);
}

.ceza-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ceza-totals {
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0.25rem;
}

.ceza-total-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-width: 50px;
}

.ceza-total-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.ceza-total-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ceza-total-value.positive {
    color: var(--danger);
}

.ceza-total-value.negative {
    color: var(--success);
}

/* Score Table */
.table-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem;
}

.score-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.score-table th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.75rem 0.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.th-type {
    width: 35px; /* Sütun daraltıldı */
}

.th-player {
    min-width: 60px;
    font-weight: 800 !important; /* İsimler çok kalın */
    color: var(--text-primary);
}

.score-table td {
    padding: 0.6rem 0.25rem;
    text-align: center;
    font-size: 1rem; /* Rakamlar büyütüldü */
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.td-type {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    width: 35px;
}

.td-type.el-type {
    color: var(--success);
}

.td-type.ceza-type {
    color: var(--warning);
}

.td-winner {
    color: var(--success) !important;
    font-weight: 700;
}

.td-high {
    color: var(--danger) !important;
}

.td-ceza {
    font-weight: 600;
}

.td-ceza.positive {
    color: var(--danger) !important;
}

.td-ceza.negative {
    color: var(--success) !important;
}

.multiplier-tag {
    font-size: 0.55rem;
    color: var(--warning);
    margin-left: 1px;
    vertical-align: super;
}

/* Total Row */
.total-row {
    background: linear-gradient(135deg, var(--accent), #5a3fd9);
}

.total-row td {
    border-bottom: none !important;
    padding: 0.875rem 0.25rem;
}

.td-total-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.td-total {
    font-size: 1.1rem;
    font-weight: 800;
    color: white;
}

/* Empty State */
.empty-row td {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-text {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ===================================
   Modal Base
   =================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 92vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0));
    animation: slideUp 0.3s ease;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-close {
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Player Tabs */
.player-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.player-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 0.25rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.player-tab.active {
    border-color: var(--warning);
    background: var(--warning);
    box-shadow: 0 4px 20px rgba(255, 184, 0, 0.5);
    transform: scale(1.05);
}

.player-tab.active .tab-name {
    color: #000;
    font-weight: 700;
}

.player-tab.active .tab-score {
    color: #000;
    font-weight: 800;
}

.player-tab.done:not(.active) {
    border-color: var(--success);
    background: rgba(0, 217, 160, 0.15);
}

.player-tab.done:not(.active) .tab-score {
    color: var(--success);
}

.tab-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.tab-score {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Score Display */
.score-display {
    text-align: center;
    padding: 1rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

#current-score {
    font-size: 2.75rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    transition: color 0.2s;
}

.score-display.negative {
    background: var(--success-glow);
    border-color: var(--success);
}

.score-display.negative #current-score {
    color: var(--success);
}

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.num-btn {
    aspect-ratio: 1.5;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-btn:active {
    background: var(--bg-elevated);
    transform: scale(0.96);
}

.num-btn.btn-clear {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.num-btn.btn-back {
    background: var(--bg-elevated);
}

.num-btn.btn-sign {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Quick Row */
.quick-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.quick-btn {
    flex: 1;
    padding: 0.65rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:active {
    background: var(--bg-elevated);
}

/* Save Button */
.btn-save {
    width: 100%;
    padding: 0.875rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-ceza-save {
    background: var(--warning);
    color: #000;
}

/* ===================================
   Toast
   =================================== */
.toast {
    position: fixed;
    bottom: calc(5rem + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 200;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--danger);
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -20px); }
}

/* Dice Styles */
.dice-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dice-container {
    perspective: 1000px;
    width: 100px;
    height: 100px;
}

.dice {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.face {
    position: absolute;
    width: 100px;
    height: 100px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.1);
}

/* Dice Dots */
.face::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #333;
}

/* Positioning faces */
.front  { transform: rotateY(0deg) translateZ(50px); }
.back   { transform: rotateY(180deg) translateZ(50px); }
.top    { transform: rotateX(90deg) translateZ(50px); }
.bottom { transform: rotateX(-90deg) translateZ(50px); }
.left   { transform: rotateY(-90deg) translateZ(50px); }
.right  { transform: rotateY(90deg) translateZ(50px); }

/* Dots distribution */
.front::before { box-shadow: 0 0 0 #333; } /* 1 */

.back::before { /* 6 */
    box-shadow: -25px -25px 0 #333, -25px 0 0 #333, -25px 25px 0 #333,
                25px -25px 0 #333, 25px 0 0 #333, 25px 25px 0 #333;
    background: transparent;
}

.top::before { /* 2 */
    box-shadow: -22px -22px 0 #333, 22px 22px 0 #333;
    background: transparent;
}

.bottom::before { /* 5 */
    box-shadow: -25px -25px 0 #333, 25px -25px 0 #333, -25px 25px 0 #333, 25px 25px 0 #333;
}

.left::before { /* 3 */
    box-shadow: -25px -25px 0 #333, 25px 25px 0 #333;
}

.right::before { /* 4 */
    box-shadow: -25px -25px 0 #333, 25px -25px 0 #333, -25px 25px 0 #333, 25px 25px 0 #333;
    background: transparent;
}

.dice-result {
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 0 20px var(--accent);
    min-height: 3.5rem;
}

/* Animations */
.rolling {
    animation: rotate 0.5s linear infinite;
}

@keyframes rotate {
    from { transform: rotateX(0) rotateY(0) rotateZ(0); }
    to { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}

/* Responsive */
@media (min-width: 768px) {
    .dice-container {
        width: 120px;
        height: 120px;
    }
    .face {
        width: 120px;
        height: 120px;
    }
    .front  { transform: rotateY(0deg) translateZ(60px); }
    .back   { transform: rotateY(180deg) translateZ(60px); }
    .top    { transform: rotateX(90deg) translateZ(60px); }
    .bottom { transform: rotateX(-90deg) translateZ(60px); }
    .left   { transform: rotateY(-90deg) translateZ(60px); }
    .right  { transform: rotateY(90deg) translateZ(60px); }
}

@media (max-height: 680px) {
    .num-btn {
        aspect-ratio: 1.7;
        font-size: 1.2rem;
    }

    .score-display {
        padding: 0.6rem;
    }

    #current-score {
        font-size: 2.25rem;
    }

    .player-tabs {
        margin-bottom: 0.5rem;
    }

    .quick-row {
        margin-bottom: 0.5rem;
    }
}

@media (min-width: 768px) {
    .modal-content {
        border-radius: var(--radius-xl);
        margin-bottom: 2rem;
    }

    .table-container {
        padding: 0 1rem;
    }
}

/* Safe Area */
@supports (padding: max(0px)) {
    .game-header {
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }
}
