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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.container {
    width: 95vw;
    height: 95vh;
    max-width: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    color: white;
    padding: 1rem;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
}

.subtitle {
    font-size: 0.8rem;
    opacity: 0.9;
}

.game-wrapper {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
}

.game-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.player-info, .ai-info {
    background: #f3f4f6;
    padding: 0.6rem;
    border-radius: 8px;
    text-align: center;
    font-size: 0.8rem;
}

.player-label, .ai-label {
    font-size: 0.7rem;
    color: #666;
}

.player-symbol, .ai-symbol {
    font-size: 1.3rem;
    font-weight: bold;
    color: #6366f1;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    aspect-ratio: 1;
}

.cell {
    aspect-ratio: 1;
    border: 2px solid #6366f1;
    border-radius: 8px;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell:hover:not(.disabled) {
    background: #f3f4f6;
    transform: scale(1.05);
}

.cell.player {
    color: #6366f1;
}

.cell.ai {
    color: #ec4899;
}

.game-status {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.6rem;
    border-radius: 8px;
    margin-bottom: 0.6rem;
    background: #f0f4ff;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

button {
    flex: 1;
    min-width: 80px;
    padding: 0.6rem 0.8rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
}

.btn-reset {
    background: #6366f1;
}

.btn-reset:hover {
    background: #4f46e5;
}

.btn-history {
    background: #ec4899;
}

.btn-history:hover {
    background: #be185d;
}

.history-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.history-container.active {
    display: flex;
}

.history-modal {
    background: white;
    border-radius: 15px;
    padding: 1rem;
    width: 90%;
    max-width: 400px;
    max-height: 70vh;
    overflow-y: auto;
}

.history-item {
    padding: 0.6rem;
    margin: 0.4rem 0;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 0.8rem;
}

@media (max-width: 480px) {
    header h1 { font-size: 1.4rem; }
    .game-board { gap: 0.4rem; }
    .cell { font-size: 1.4rem; }
}
