:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --accent-cyan: #00f5ff;
    --accent-magenta: #ff00aa;
    --accent-gold: #ffd700;
    --accent-purple: #8b5cf6;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --grid-line: rgba(255, 255, 255, 0.08);
    --glow-cyan: 0 0 20px rgba(0, 245, 255, 0.5);
    --glow-magenta: 0 0 20px rgba(255, 0, 170, 0.5);

    /* テトリミノカラー */
    --piece-I: #00f5ff;
    --piece-O: #ffd700;
    --piece-T: #8b5cf6;
    --piece-S: #00ff88;
    --piece-Z: #ff4757;
    --piece-J: #3b82f6;
    --piece-L: #ff8c00;
    --piece-ghost: rgba(255, 255, 255, 0.15);
    --piece-garbage: #4a4a5a;
}

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

body {
    font-family: 'Rajdhani', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 背景エフェクト */
.bg-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.bg-effects::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(0, 245, 255, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(255, 0, 170, 0.1) 0%, transparent 50%);
}

.scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px);
    animation: scanMove 8s linear infinite;
}

@keyframes scanMove {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(4px);
    }
}

/* メインコンテナ */
.game-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
.header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--grid-line);
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(10px);
}

.logo {
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: var(--glow-cyan);
}

.match-info {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.timer {
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ゲームエリア - PC版 */
.game-area {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    align-items: center;
    justify-items: center;
}

/* プレイヤーセクション */
.player-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.player-name {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.player-section.player .player-name {
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.2), rgba(0, 245, 255, 0.05));
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.player-section.opponent .player-name {
    background: linear-gradient(135deg, rgba(255, 0, 170, 0.2), rgba(255, 0, 170, 0.05));
    border: 1px solid var(--accent-magenta);
    color: var(--accent-magenta);
    box-shadow: var(--glow-magenta);
}

.game-board-wrapper {
    position: relative;
    display: flex;
    gap: 0.75rem;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panel-box {
    background: var(--bg-secondary);
    border: 1px solid var(--grid-line);
    border-radius: 8px;
    padding: 0.75rem;
    min-width: 100px;
}

.panel-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    text-align: center;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    aspect-ratio: 4/4;
}

.preview-cell {
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    color: var(--accent-gold);
}

/* ゲームボード */
.game-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 1px;
    background: var(--bg-secondary);
    border: 2px solid var(--grid-line);
    border-radius: 8px;
    padding: 4px;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(0, 0, 0, 0.3);
}

.player .game-board {
    width: 320px;
    border-color: rgba(0, 245, 255, 0.3);
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(0, 245, 255, 0.1);
}

.opponent .game-board {
    width: 320px;
    border-color: rgba(255, 0, 170, 0.3);
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(255, 0, 170, 0.1);
}

/* アテナ様の顔アイコン */
.athena-face-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 0.5rem;
}

.athena-face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 3px solid var(--accent-magenta);
    box-shadow:
        var(--glow-magenta),
        inset 0 0 20px rgba(255, 0, 170, 0.2);
    object-fit: cover;
    position: relative;
    z-index: 2;
}

.athena-face-glow {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 0, 170, 0.4) 0%, transparent 70%);
    z-index: 1;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.athena-status {
    font-size: 0.8rem;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
    min-height: 1.2em;
    text-align: center;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.cell {
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border-radius: 2px;
    transition: all 0.05s ease;
}

.cell.filled {
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.2);
}

.cell.I {
    background: var(--piece-I);
}

.cell.O {
    background: var(--piece-O);
}

.cell.T {
    background: var(--piece-T);
}

.cell.S {
    background: var(--piece-S);
}

.cell.Z {
    background: var(--piece-Z);
}

.cell.J {
    background: var(--piece-J);
}

.cell.L {
    background: var(--piece-L);
}

.cell.ghost {
    background: var(--piece-ghost);
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.cell.garbage {
    background: var(--piece-garbage);
}

.cell.clearing {
    animation: clearLine 0.3s ease-out;
}

@keyframes clearLine {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
        background: white;
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* 中央パネル */
.center-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
}

.vs-badge {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.attack-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.attack-bar {
    width: 20px;
    height: 150px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.attack-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(to top, var(--accent-magenta), var(--accent-cyan));
    transition: height 0.3s ease;
    border-radius: 10px;
}

.attack-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* スコアボード */
.scoreboard {
    background: var(--bg-secondary);
    border: 1px solid var(--grid-line);
    border-radius: 8px;
    padding: 1rem;
    min-width: 120px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--grid-line);
}

.score-row:last-child {
    border-bottom: none;
}

.score-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.score-value {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
}

.score-value.player-score {
    color: var(--accent-cyan);
}

.score-value.opponent-score {
    color: var(--accent-magenta);
}

/* コントロール */
.controls-area {
    display: none;
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--grid-line);
}

.touch-controls {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    max-width: 400px;
    margin: 0 auto;
}

.touch-btn {
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border: 2px solid var(--grid-line);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.touch-btn:active {
    transform: scale(0.95);
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.touch-btn.rotate {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.1));
    border-color: var(--accent-purple);
}

.touch-btn.drop {
    background: linear-gradient(135deg, rgba(255, 0, 170, 0.3), rgba(255, 0, 170, 0.1));
    border-color: var(--accent-magenta);
}

/* オーバーレイ */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.game-overlay.hidden {
    display: none;
}

.overlay-title {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.overlay-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    text-align: center;
}

.start-btn {
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 1rem 3rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    border: none;
    border-radius: 8px;
    color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 245, 255, 0.3);
}

.controls-hint {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    max-width: 400px;
}

.controls-hint h3 {
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    text-align: center;
}

.key-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    font-size: 0.9rem;
}

.key {
    font-family: 'Orbitron', monospace;
    background: var(--bg-tertiary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* 勝敗画面 */
.result-screen {
    text-align: center;
}

.result-title {
    font-family: 'Orbitron', monospace;
    font-size: 4rem;
    font-weight: 900;
    margin-bottom: 1rem;
}

.result-title.win {
    color: var(--accent-cyan);
    text-shadow: var(--glow-cyan);
}

.result-title.lose {
    color: var(--accent-magenta);
    text-shadow: var(--glow-magenta);
}

.result-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 2rem 0;
}

.result-stat {
    text-align: center;
}

.result-stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.result-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* より大きな画面用 */
@media (min-width: 1400px) {

    .player .game-board,
    .opponent .game-board {
        width: 380px;
    }

    .athena-face-container {
        width: 140px;
        height: 140px;
    }

    .panel-box {
        min-width: 120px;
        padding: 1rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .preview-grid {
        gap: 4px;
    }
}

@media (min-width: 1600px) {

    .player .game-board,
    .opponent .game-board {
        width: 440px;
    }

    .athena-face-container {
        width: 160px;
        height: 160px;
    }
}

/* スマホ・タブレット対応 */
@media (max-width: 900px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .match-info {
        gap: 1rem;
    }

    .timer {
        font-size: 1rem;
    }

    .game-area {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 1rem;
        padding: 0.75rem;
    }

    /* スマホ版: 案2レイアウト */
    .mobile-top-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        width: 100%;
    }

    .opponent-mini {
        background: var(--bg-secondary);
        border: 1px solid rgba(255, 0, 170, 0.3);
        border-radius: 8px;
        padding: 0.5rem;
    }

    .opponent-mini .mini-label {
        font-size: 0.65rem;
        color: var(--accent-magenta);
        text-transform: uppercase;
        margin-bottom: 0.25rem;
        text-align: center;
    }

    .opponent-mini .mini-board {
        display: grid;
        grid-template-columns: repeat(10, 1fr);
        gap: 1px;
        background: var(--bg-tertiary);
        border-radius: 4px;
        padding: 2px;
    }

    .opponent-mini .mini-cell {
        aspect-ratio: 1;
        background: var(--bg-primary);
        border-radius: 1px;
    }

    .opponent-mini .mini-cell.filled {
        opacity: 1;
    }

    .opponent-mini .mini-cell.I {
        background: var(--piece-I);
    }

    .opponent-mini .mini-cell.O {
        background: var(--piece-O);
    }

    .opponent-mini .mini-cell.T {
        background: var(--piece-T);
    }

    .opponent-mini .mini-cell.S {
        background: var(--piece-S);
    }

    .opponent-mini .mini-cell.Z {
        background: var(--piece-Z);
    }

    .opponent-mini .mini-cell.J {
        background: var(--piece-J);
    }

    .opponent-mini .mini-cell.L {
        background: var(--piece-L);
    }

    .opponent-mini .mini-cell.garbage {
        background: var(--piece-garbage);
    }

    .mobile-info-panel {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-info-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .mobile-panel-box {
        background: var(--bg-secondary);
        border: 1px solid var(--grid-line);
        border-radius: 6px;
        padding: 0.4rem;
        text-align: center;
    }

    .mobile-panel-box .panel-label {
        font-size: 0.6rem;
        margin-bottom: 0.25rem;
    }

    .mobile-preview {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1px;
        width: 40px;
        margin: 0 auto;
    }

    .mobile-preview .preview-cell {
        width: 10px;
        height: 10px;
    }

    .mobile-stat {
        font-family: 'Orbitron', monospace;
        font-size: 1rem;
        font-weight: 700;
        color: var(--accent-gold);
    }

    .player-section.player {
        order: 1;
        width: 100%;
    }

    .player-section.opponent {
        display: none;
    }

    .center-panel {
        display: none;
    }

    .player .game-board {
        width: 100%;
        max-width: 320px;
    }

    .player .side-panel {
        display: none;
    }

    .player .player-name {
        display: none;
    }

    .controls-area {
        display: block;
    }

    .controls-hint {
        display: none;
    }

    .overlay-title {
        font-size: 2rem;
    }

    .result-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 400px) {
    .touch-btn {
        font-size: 1.2rem;
    }

    .mobile-top-bar {
        gap: 0.5rem;
    }
}

/* PC版では非表示 */
@media (min-width: 901px) {
    .mobile-top-bar {
        display: none;
    }
}

/* アニメーション */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.3s ease;
}

@keyframes flashAttack {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
    }
}

.flash-attack {
    animation: flashAttack 0.2s ease 3;
}