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

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

.game-container {
    width: 100%;
    max-width: 1400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    animation: fadeIn 0.5s ease-in;
}

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

.header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

.header h1 {
    color: #667eea;
    font-size: 2.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.info-item {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.game-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
}

.ai-players {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    height: 150px;
}

.main-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    min-height: 450px;
}

.player-area {
    background: linear-gradient(145deg, #f5f7fa, #e4e8eb);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.player-area:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

.player-area.active {
    border: 3px solid #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

.player-top {
    grid-area: top;
    flex-direction: column-reverse;
}

.player-left {
    grid-area: left;
}

.player-right {
    grid-area: right;
}

.player-bottom {
    grid-area: bottom;
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    width: 100%;
}

.player-name {
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
}

.player-score {
    color: #667eea;
    font-weight: bold;
}

.player-hand {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 80px;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.player-top .player-hand,
.player-bottom .player-hand {
    flex-direction: row;
    max-width: 100%;
    overflow-x: auto;
}

.player-left .player-hand,
.player-right .player-hand {
    flex-direction: column;
    max-height: 100%;
    overflow-y: auto;
}

.player-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    min-height: 40px;
}

.center-area {
    grid-area: center;
    background: linear-gradient(145deg, #2d5016, #1a3009);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: inset 0 5px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
    overflow: hidden;
}

.center-area::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    z-index: 0;
}

.center-area > * {
    position: relative;
    z-index: 1;
}

.discard-pile {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    min-height: 150px;
    overflow: auto;
    max-height: 400px;
}

.game-message {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.2em;
    color: #333;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.current-action {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.tile {
    width: 45px;
    height: 63px;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border: 2px solid #ccc;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    user-select: none;
    z-index: 1;
}

.tile:hover {
    transform: translateY(-8px) scale(1.2);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.4);
    z-index: 20;
}

.ai-player .tile {
    width: 30px;
    height: 42px;
    font-size: 0.8em;
    background: linear-gradient(145deg, #1a5f2a, #0d3d18);
    color: transparent;
    border-color: #0d3d18;
}

.ai-player .tile::before {
    content: '🀫';
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.5em;
}

.ai-player .tile:hover {
    transform: translateY(-5px) scale(1.1);
}

.tile.selected {
    transform: translateY(-10px);
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.6);
    border-color: #667eea;
}

.tile.wan {
    color: #c41e3a;
}

.tile.tiao {
    color: #228b22;
}

.tile.tong {
    color: #1e90ff;
}

.tile.wind {
    color: #4a4a4a;
}

.tile.dragon {
    color: #8b0000;
}

.tile.flower {
    color: #ff69b4;
}

.tile.hidden {
    background: linear-gradient(145deg, #1a5f2a, #0d3d18);
    color: transparent;
    border-color: #0d3d18;
}

.tile.hidden::before {
    content: '🀫';
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.2em;
}

.tile.just-drawn {
    animation: drawTile 0.5s ease-out;
}

@keyframes drawTile {
    0% {
        transform: translateY(-100px) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: translateY(-50px) rotate(90deg);
        opacity: 0.5;
    }
    100% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
}

.tile.dealing {
    animation: dealTile 0.3s ease-out;
}

@keyframes dealTile {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.tile.discarded {
    animation: discard 0.3s ease-out;
}

@keyframes discard {
    from {
        transform: scale(1.2);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.control-panel {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 15px;
    background: linear-gradient(145deg, #f5f7fa, #e4e8eb);
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
    margin-top: 20px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #f5576c, #f093fb);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    color: #333;
    font-size: 1.2em;
    margin-bottom: 30px;
    line-height: 1.6;
}

@media (max-width: 1200px) {
    .game-container {
        padding: 20px;
    }
    
    .game-table {
        grid-template-columns: 150px 1fr 150px;
        grid-template-rows: 150px 1fr 150px;
        min-height: 500px;
    }
    
    .tile {
        width: 40px;
        height: 56px;
        font-size: 1.2em;
    }
    
    .player-area {
        padding: 10px;
    }
    
    .center-area {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }
    
    .game-info {
        gap: 15px;
    }
    
    .info-item {
        padding: 6px 15px;
        font-size: 0.9em;
    }
    
    .tile {
        width: 35px;
        height: 50px;
        font-size: 1em;
    }
    
    .control-panel {
        gap: 10px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }
}

.action-button {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.action-button.chi {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
}

.action-button.peng {
    background: linear-gradient(135deg, #fa709a, #fee140);
    color: white;
}

.action-button.gang {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    color: #333;
}

.action-button.hu {
    background: linear-gradient(135deg, #ff9a9e, #fecfef);
    color: white;
}

.action-button.pass {
    background: linear-gradient(135deg, #cfd9df, #e2ebf0);
    color: #333;
}
