/* ===== Dice Roller Styles ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark, #050505);
    color: var(--text-main, #ffffff);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

/* ===== Header ===== */
.g4f-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main, #fff);
    font-size: 1.2rem;
    font-weight: 600;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--secondary-neon, #ec4899));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.highlight-4 {
    color: var(--secondary-neon, #ec4899);
    font-weight: 700;
}

.lang-switch {
    display: flex;
    gap: 6px;
}

.lang-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.15));
    background: transparent;
    color: var(--text-dim, #888);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.lang-btn.active {
    background: var(--primary-neon, #6366f1);
    color: #fff;
    border-color: var(--primary-neon, #6366f1);
}

/* ===== Game Container ===== */
.game-container {
    flex: 1;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.game-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--secondary-neon, #ec4899));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Controls Bar ===== */
.controls-bar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    padding: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-inline {
    flex-direction: row;
    align-items: center;
}

.control-label {
    font-size: 0.85rem;
    color: var(--text-dim, #999);
    font-weight: 500;
}

.selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.sel-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.15));
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim, #aaa);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 44px;
    text-align: center;
}

.sel-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
}

.sel-btn.active {
    background: var(--primary-neon, #6366f1);
    color: #fff;
    border-color: var(--primary-neon, #6366f1);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dim, #aaa);
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-neon, #6366f1);
    cursor: pointer;
}

/* ===== Roll Area ===== */
.roll-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.dice-tray {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    min-height: 100px;
    padding: 24px;
    width: 100%;
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
}

/* ===== Dice Styles ===== */
.die {
    position: relative;
    width: 80px;
    height: 80px;
    perspective: 300px;
}

.die-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.9), rgba(15, 15, 20, 0.95));
    border: 2px solid var(--primary-neon, #6366f1);
    border-radius: 14px;
    box-shadow:
        0 0 15px rgba(99, 102, 241, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    transition: transform 0.15s, box-shadow 0.15s;
}

.die.rolling .die-inner {
    animation: dieTumble 0.6s ease-out;
}

@keyframes dieTumble {
    0%   { transform: rotateX(0deg) rotateY(0deg) scale(0.8); }
    20%  { transform: rotateX(180deg) rotateY(90deg) scale(1.1); }
    40%  { transform: rotateX(360deg) rotateY(180deg) scale(0.95); }
    60%  { transform: rotateX(540deg) rotateY(270deg) scale(1.05); }
    80%  { transform: rotateX(680deg) rotateY(340deg) scale(1.0); }
    100% { transform: rotateX(720deg) rotateY(360deg) scale(1.0); }
}

.die.landed .die-inner {
    box-shadow:
        0 0 20px rgba(99, 102, 241, 0.5),
        0 0 40px rgba(99, 102, 241, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* d6 pip layout */
.pip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    width: 52px;
    height: 52px;
    padding: 4px;
}

.pip {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--secondary-neon, #ec4899);
    box-shadow: 0 0 6px rgba(236, 72, 153, 0.6);
    align-self: center;
    justify-self: center;
    visibility: hidden;
}

.pip.show { visibility: visible; }

/* Non-d6 number display */
.die-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--secondary-neon, #ec4899);
    text-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
}

/* Die shape variants */
.die.d4 .die-inner { border-radius: 4px; clip-path: polygon(50% 5%, 5% 95%, 95% 95%); }
.die.d8 .die-inner { border-radius: 4px; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.die.d10 .die-inner { border-radius: 4px; clip-path: polygon(50% 0%, 95% 38%, 80% 95%, 20% 95%, 5% 38%); }
.die.d12 .die-inner { border-radius: 4px; clip-path: polygon(50% 0%, 85% 15%, 100% 50%, 85% 85%, 50% 100%, 15% 85%, 0% 50%, 15% 15%); }
.die.d20 .die-inner { border-radius: 4px; clip-path: polygon(50% 0%, 90% 20%, 100% 60%, 75% 95%, 25% 95%, 0% 60%, 10% 20%); }

/* Total Display */
.total-display {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
}

.total-label {
    color: var(--text-dim, #999);
    font-weight: 500;
}

.total-value {
    font-size: 2.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--secondary-neon, #ec4899));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 60px;
    text-align: center;
}

.total-value.pop {
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0%   { transform: scale(0.5); opacity: 0; }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* Roll Button */
.neon-btn {
    padding: 14px 40px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.neon-btn.primary {
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--secondary-neon, #ec4899));
    color: #fff;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.neon-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.55);
}

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

.neon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.roll-btn {
    font-size: 1.2rem;
    padding: 16px 56px;
}

.shake-hint {
    font-size: 0.8rem;
    color: var(--text-dim, #666);
}

/* ===== History Panel ===== */
.history-panel, .stats-panel {
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    padding: 20px;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-main, #fff);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 2px; }

.empty-hint {
    color: var(--text-dim, #666);
    font-size: 0.85rem;
    text-align: center;
    padding: 16px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-size: 0.85rem;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.history-dice {
    color: var(--text-dim, #aaa);
    font-family: 'Courier New', monospace;
}

.history-total {
    font-weight: 700;
    color: var(--primary-neon, #6366f1);
}

.history-type {
    color: var(--text-dim, #666);
    font-size: 0.75rem;
}

/* ===== Stats Panel ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-dim, #888);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main, #fff);
}

.chart-title {
    font-size: 0.9rem;
    color: var(--text-dim, #999);
    margin-bottom: 10px;
    font-weight: 500;
}

.distribution-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 8px 0;
}

.chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.chart-bar {
    width: 100%;
    max-width: 32px;
    background: linear-gradient(180deg, var(--primary-neon, #6366f1), rgba(99, 102, 241, 0.3));
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.3s ease-out;
    align-self: center;
    margin-top: auto;
}

.chart-label {
    font-size: 0.65rem;
    color: var(--text-dim, #666);
}

.chart-count {
    font-size: 0.6rem;
    color: var(--text-dim, #888);
}

/* ===== Ad + Footer ===== */
.g4f-ad-container {
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.ad-placeholder-content {
    color: var(--text-dim, #555);
    font-size: 0.85rem;
}

.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-dim, #555);
    font-size: 0.8rem;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .game-container { padding: 16px 10px; gap: 18px; }
    .game-title { font-size: 1.4rem; }
    .die { width: 64px; height: 64px; }
    .pip-grid { width: 42px; height: 42px; gap: 3px; }
    .pip { width: 10px; height: 10px; }
    .die-number { font-size: 1.4rem; }
    .roll-btn { padding: 14px 40px; font-size: 1rem; }
    .total-value { font-size: 2rem; }
    .sel-btn { padding: 6px 12px; font-size: 0.8rem; min-width: 38px; }
    .controls-bar { padding: 14px; }
    .distribution-chart { height: 90px; }
}
