@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700&display=swap');

:root {
    --bg-color: #050505;
    --panel-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --accent-color: #00d2ff;

    --color-i: #00f0f0;
    --color-j: #0070ff;
    --color-l: #ff9d00;
    --color-o: #ffdb00;
    --color-s: #00ff00;
    --color-t: #b000ff;
    --color-z: #ff0040;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    background: radial-gradient(circle at center, #111 0%, #050505 100%);
}

.game-container {
    display: flex;
    gap: 24px;
    padding: 30px;
    border-radius: 24px;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    align-items: flex-start;
}

/* ── 中央：ゲーム盤 ── */
.main-board-container {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    background: #000;
    border: 3px solid var(--glass-border);
    outline: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

canvas#tetris {
    display: block;
    background-color: transparent;
}

/* ── 左：サイドパネル ── */
.side-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 160px;
    height: 600px;
    flex-shrink: 0;
}

.stats-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-row {
    display: flex;
    gap: 6px;
}

.stats-row .stat-box {
    flex: 1;
    padding: 8px 4px;
}

.stats-row .stat-value {
    font-size: 16px;
}

.stats-row .stat-label {
    font-size: 9px;
    letter-spacing: 1px;
}

.stat-box {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    text-align: center;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.next-piece-container {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#next-canvas {
    margin-top: 8px;
}

.controls-hint {
    margin-top: auto;
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.7;
    background: rgba(255, 255, 255, 0.02);
    padding: 12px;
    border-radius: 12px;
}

.controls-hint b {
    color: var(--accent-color);
}

/* ── 右：ランキングパネル ── */
.ranking-panel {
    width: 200px;
    height: 600px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.ranking-panel-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--glass-border);
    text-align: center;
    background: rgba(0, 210, 255, 0.04);
    flex-shrink: 0;
}

.ranking-list-full {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.ranking-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 7px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}

.ranking-entry:hover {
    background: rgba(255,255,255,0.04);
}

.ranking-entry.me {
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.25);
}

.rank-num {
    width: 20px;
    text-align: right;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 11px;
    flex-shrink: 0;
}

.ranking-entry:nth-child(1) .rank-num { color: #ffd700; font-size: 13px; }
.ranking-entry:nth-child(2) .rank-num { color: #c0c0c0; }
.ranking-entry:nth-child(3) .rank-num { color: #cd7f32; }

.rank-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.rank-score {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 11px;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.ranking-entry.me .rank-name,
.ranking-entry.me .rank-score { color: var(--accent-color); }

.ranking-empty {
    color: var(--text-secondary);
    font-size: 11px;
    text-align: center;
    padding: 20px 0;
}

/* ── ゲームオーバーオーバーレイ ── */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    animation: fadeIn 0.3s ease-out;
}

.game-over-title {
    font-size: 42px;
    font-weight: 700;
    color: var(--color-z);
    text-shadow: 0 0 20px rgba(255, 0, 64, 0.5);
    margin-bottom: 16px;
}

.btn-restart {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    background: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 210, 255, 0.3);
}

/* ── 名前入力 ── */
.name-input {
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    padding: 8px 14px;
    width: 200px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

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

.name-input::placeholder {
    color: rgba(255,255,255,0.3);
}

.btn-submit {
    padding: 9px 22px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}

.btn-submit:hover:not(:disabled) {
    background: var(--accent-color);
    color: #000;
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: default;
}

.rank-result-text {
    color: var(--accent-color);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

/* ── アニメーション ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes flash {
    0% { filter: brightness(1); }
    50% { filter: brightness(3); }
    100% { filter: brightness(1); }
}

.line-flash {
    animation: flash 0.2s ease-out;
}

.clear-msg {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-color);
    font-size: 22px;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(0, 210, 255, 0.9), 0 0 40px rgba(0, 210, 255, 0.4);
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    text-align: center;
    z-index: 5;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.clear-msg.show {
    animation: popMsg 1.3s ease-out forwards;
}

@keyframes popMsg {
    0%   { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
    15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
    35%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── イースターエッグ モーダル ── */
.easter-egg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 1s ease-out;
}

.easter-egg-content {
    background: rgba(10, 10, 15, 0.8);
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 50px rgba(0, 210, 255, 0.2), inset 0 0 20px rgba(0, 210, 255, 0.1);
    border-radius: 4px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.easter-egg-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    animation: scanline 2s linear infinite;
}

@keyframes scanline {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.easter-egg-title {
    color: var(--accent-color);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 4px;
    margin-bottom: 24px;
    text-shadow: 0 0 10px rgba(0, 210, 255, 0.8);
}

.easter-egg-text {
    color: #e0e0e0;
    font-size: 14px;
    line-height: 1.8;
    text-align: left;
    margin-bottom: 30px;
    overflow-y: auto;
    padding-right: 15px;
    /* Custom Scrollbar for this div */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) rgba(255,255,255,0.1);
}

.easter-egg-text::-webkit-scrollbar {
    width: 6px;
}
.easter-egg-text::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}
.easter-egg-text::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 10px;
}

