@charset "UTF-8";

/* ==========================================================================
   TimeStop - Cyberpunk Extreme Chicken-Race & Internal Clock Game
   ========================================================================== */

:root {
    --bg-dark: #07070c;
    --bg-surface: rgba(18, 18, 28, 0.85);
    --bg-surface-elevated: rgba(28, 28, 44, 0.9);
    --border-color: rgba(255, 255, 255, 0.12);
    --border-glow: rgba(0, 240, 255, 0.4);
    
    --neon-cyan: #00f0ff;
    --neon-magenta: #ff0055;
    --neon-amber: #ffaa00;
    --neon-emerald: #00ff88;
    --neon-purple: #9d4edd;
    
    --text-primary: #ffffff;
    --text-secondary: #9ba1b5;
    --text-muted: #61667d;
    
    --font-digit: 'Orbitron', monospace;
    --font-main: 'Noto Sans JP', 'Inter', -apple-system, sans-serif;
    
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    flex-direction: column;
}

/* Background Cyber Grid & Ambient Glow */
.cyber-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: 
        radial-gradient(ellipse at 50% 10%, rgba(0, 240, 255, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 90%, rgba(255, 0, 85, 0.08) 0%, transparent 55%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    background-position: 0 0, 0 0, -1px -1px, -1px -1px;
}

/* Header */
header {
    position: relative;
    z-index: 20;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: rgba(10, 10, 18, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

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

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    transition: var(--transition-fast);
}

.back-link:hover {
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 28px;
    height: 28px;
    border: 2px solid var(--neon-cyan);
    display: grid;
    place-items: center;
    color: var(--neon-cyan);
    font-size: 0.85rem;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
    transform: rotate(45deg);
}

.logo-icon i {
    transform: rotate(-45deg);
}

.logo-text {
    font-family: var(--font-digit);
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.logo-text span {
    color: var(--neon-magenta);
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
}

.badge-beta {
    font-size: 0.65rem;
    font-family: var(--font-digit);
    background: rgba(0, 240, 255, 0.15);
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
    padding: 0.15rem 0.4rem;
    border-radius: 2px;
    letter-spacing: 0.1em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-btn:hover, .icon-btn.active {
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

/* Main Container */
main {
    position: relative;
    z-index: 10;
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Control Bar (Mode & Range) */
.control-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.control-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.pill-group {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.pill-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pill-btn:hover {
    color: #fff;
}

.pill-btn.active {
    background: var(--neon-cyan);
    color: #050508;
    font-weight: 700;
    box-shadow: 0 0 14px rgba(0, 240, 255, 0.5);
}

.pill-btn.active.blind-mode {
    background: var(--neon-magenta);
    box-shadow: 0 0 14px rgba(255, 0, 85, 0.5);
    color: #fff;
}

/* Game Card Area */
.game-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.game-card.state-running {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.25), inset 0 0 20px rgba(0, 240, 255, 0.05);
}

.game-card.state-danger {
    border-color: var(--neon-magenta);
    box-shadow: 0 0 35px rgba(255, 0, 85, 0.35), inset 0 0 25px rgba(255, 0, 85, 0.08);
    animation: pulseBorder 0.8s infinite alternate;
}

.game-card.state-over {
    border-color: var(--neon-magenta);
    animation: glitchShake 0.4s ease;
}

.game-card.state-cleared {
    border-color: var(--neon-emerald);
    box-shadow: 0 0 35px rgba(0, 255, 136, 0.35);
}

/* Target Time Display */
.target-box {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.target-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--neon-cyan);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.target-value-wrapper {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
}

.target-time {
    font-family: var(--font-digit);
    font-size: 3.2rem;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.05em;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.6);
}

.target-unit {
    font-family: var(--font-digit);
    font-size: 1.3rem;
    color: var(--neon-cyan);
    font-weight: 700;
}

.target-range-badge {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.08em;
}

/* Main Timer Screen */
.timer-screen {
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 2.2rem 1.5rem;
    text-align: center;
    position: relative;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.timer-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.6), transparent);
}

.status-indicator {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.75rem;
    font-family: var(--font-digit);
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition-fast);
}

.status-dot.active {
    background: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan);
    animation: blink 0.8s infinite;
}

.status-dot.danger {
    background: var(--neon-magenta);
    box-shadow: 0 0 10px var(--neon-magenta);
    animation: blink 0.4s infinite;
}

.timer-digits {
    font-family: var(--font-digit);
    font-size: clamp(3.2rem, 9vw, 5.8rem);
    font-weight: 900;
    letter-spacing: 0.06em;
    color: #ffffff;
    line-height: 1;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.2rem;
    text-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
}

.timer-digits.blind-active {
    letter-spacing: 0.2em;
    color: var(--neon-magenta);
    text-shadow: 0 0 25px rgba(255, 0, 85, 0.6);
}

.timer-sec {
    color: #ffffff;
}

.timer-delim {
    color: var(--neon-cyan);
    opacity: 0.8;
}

.timer-ms {
    color: var(--neon-cyan);
    font-size: 0.75em;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.6);
}

.timer-digits.warning .timer-ms,
.timer-digits.warning .timer-delim {
    color: var(--neon-amber);
    text-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
}

.timer-digits.danger .timer-ms,
.timer-digits.danger .timer-delim {
    color: var(--neon-magenta);
    text-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
}

/* Progress Gauge */
.progress-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 1.5rem;
    position: relative;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-emerald));
    border-radius: 999px;
    transition: width 0.05s linear;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
}

.progress-bar.warning {
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-amber));
    box-shadow: 0 0 12px rgba(255, 170, 0, 0.6);
}

.progress-bar.danger {
    background: linear-gradient(90deg, var(--neon-amber), var(--neon-magenta));
    box-shadow: 0 0 14px rgba(255, 0, 85, 0.8);
}

.progress-bar.blind-masked {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

/* Stat Metrics Grid */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.metric-card {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    text-align: center;
}

.metric-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

.metric-val {
    font-family: var(--font-digit);
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
}

.metric-val.highlight-cyan {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.metric-val.highlight-magenta {
    color: var(--neon-magenta);
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.4);
}

.metric-val.highlight-emerald {
    color: var(--neon-emerald);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}

/* Big Action Button */
.action-area {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    align-items: center;
}

.btn-trigger {
    width: 100%;
    max-width: 460px;
    padding: 1.4rem 2rem;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(0, 240, 255, 0.05));
    border: 2px solid var(--neon-cyan);
    border-radius: 14px;
    color: #fff;
    font-family: var(--font-digit);
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.3), inset 0 0 15px rgba(0, 240, 255, 0.1);
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.btn-trigger:hover {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.25), rgba(0, 240, 255, 0.1));
    box-shadow: 0 0 35px rgba(0, 240, 255, 0.5), inset 0 0 20px rgba(0, 240, 255, 0.2);
    transform: translateY(-2px);
}

.btn-trigger:active {
    transform: translateY(1px);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.btn-trigger.running {
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.2), rgba(255, 0, 85, 0.08));
    border-color: var(--neon-magenta);
    box-shadow: 0 0 28px rgba(255, 0, 85, 0.4), inset 0 0 15px rgba(255, 0, 85, 0.15);
}

.btn-trigger.running:hover {
    box-shadow: 0 0 40px rgba(255, 0, 85, 0.6), inset 0 0 25px rgba(255, 0, 85, 0.25);
}

.btn-trigger-sub {
    font-family: var(--font-main);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.kbd-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    font-family: var(--font-digit);
    font-size: 0.7rem;
    color: #fff;
}

/* Secondary Button Row (FIX / RESET) */
.sub-actions {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    max-width: 460px;
}

.btn-sub {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.btn-sub:hover:not(:disabled) {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-sub.btn-fix {
    border-color: rgba(0, 255, 136, 0.3);
    color: var(--neon-emerald);
}

.btn-sub.btn-fix:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.15);
    border-color: var(--neon-emerald);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
    color: #fff;
}

.btn-sub:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Lower Area: Logs & High Scores */
.bottom-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
}

.section-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--neon-cyan);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tick Logs Table */
.logs-container {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.log-table th {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: var(--font-digit);
}

.log-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.log-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2rem 0;
}

/* High Score List */
.best-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.best-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.best-item-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.best-item-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.best-item-val {
    font-family: var(--font-digit);
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}

/* Modal Overlay (Result) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-smooth);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-surface-elevated);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    max-width: 460px;
    width: 100%;
    padding: 2.2rem;
    text-align: center;
    transform: scale(0.92);
    transition: transform var(--transition-smooth);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-card.state-win {
    border-color: var(--neon-emerald);
    box-shadow: 0 0 50px rgba(0, 255, 136, 0.35);
}

.modal-card.state-lose {
    border-color: var(--neon-magenta);
    box-shadow: 0 0 50px rgba(255, 0, 85, 0.35);
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto 1.25rem;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
}

.modal-card.state-win .modal-icon {
    background: rgba(0, 255, 136, 0.15);
    color: var(--neon-emerald);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

.modal-card.state-lose .modal-icon {
    background: rgba(255, 0, 85, 0.15);
    color: var(--neon-magenta);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.4);
}

.modal-title {
    font-family: var(--font-digit);
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    margin-bottom: 0.3rem;
}

.modal-card.state-win .modal-title {
    color: var(--neon-emerald);
}

.modal-card.state-lose .modal-title {
    color: var(--neon-magenta);
}

.modal-msg {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.modal-stats {
    background: rgba(0, 0, 0, 0.45);
    border-radius: 10px;
    padding: 1.25rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-btn-row {
    display: flex;
    gap: 0.75rem;
}

.modal-btn {
    flex: 1;
    padding: 0.9rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    font-family: var(--font-main);
}

.modal-btn-primary {
    background: var(--neon-cyan);
    color: #050508;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.modal-btn-primary:hover {
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.7);
    transform: translateY(-2px);
}

/* Animations */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

@keyframes pulseBorder {
    0% { box-shadow: 0 0 25px rgba(255, 0, 85, 0.3); }
    100% { box-shadow: 0 0 45px rgba(255, 0, 85, 0.7); }
}

@keyframes glitchShake {
    0% { transform: translate(0); }
    20% { transform: translate(-4px, 4px); }
    40% { transform: translate(4px, -4px); }
    60% { transform: translate(-3px, 2px); }
    80% { transform: translate(3px, -2px); }
    100% { transform: translate(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .control-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .control-group {
        justify-content: space-between;
    }
    .metrics-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .bottom-grid {
        grid-template-columns: 1fr;
    }
    .target-time {
        font-size: 2.5rem;
    }
    .btn-trigger {
        font-size: 1.15rem;
        padding: 1.1rem;
    }
}
