* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Malgun Gothic', 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 헤더 - 컴팩트 */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.player-details {
    display: flex;
    flex-direction: column;
}

#current-player {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

#player-money {
    font-size: 12px;
    color: #666;
}

.info-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 2px solid #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.info-btn svg {
    color: #667eea;
}

.info-btn:active {
    transform: scale(0.9);
    background: #f0f0f0;
}

/* 메인 - 게임 보드 중심 */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    position: relative;
    overflow: hidden;
}

/* 게임 보드 - 전체 화면 */
.game-board {
    width: 100%;
    max-width: min(100vw - 30px, 100vh - 150px);
    aspect-ratio: 1;
    background: #90ee90;
    border: 5px solid #8b4513;
    border-radius: 8px;
    position: relative;
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    grid-template-rows: repeat(11, 1fr);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* 보드 칸 */
.cell {
    border: 1px solid #666;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2px;
    font-size: 7px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.cell.corner {
    font-size: 8px;
    font-weight: bold;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
}

.cell.start {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.cell.island {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.cell-name {
    font-weight: bold;
    line-height: 1.1;
    word-break: keep-all;
}

.cell-price {
    font-size: 6px;
    color: #666;
    margin-top: 1px;
}

.cell-color {
    width: 100%;
    height: 8px;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.cell.owned {
    background: #ffe4b5;
}

.owner-indicator {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid white;
}

.buildings {
    display: flex;
    gap: 1px;
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
}

.building {
    width: 5px;
    height: 5px;
    background: #32cd32;
    border: 1px solid #228b22;
}

.building.hotel {
    background: #ff4444;
    border-color: #cc0000;
}

/* 플레이어 토큰 */
.player-tokens {
    display: flex;
    gap: 2px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

.player-token {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3),
                0 4px 8px rgba(0, 0, 0, 0.5),
                0 0 20px rgba(255, 255, 255, 0.4);
    animation: token-pulse 2s ease-in-out infinite;
}

@keyframes token-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3),
                    0 4px 8px rgba(0, 0, 0, 0.5),
                    0 0 20px rgba(255, 255, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3),
                    0 4px 12px rgba(0, 0, 0, 0.6),
                    0 0 30px rgba(255, 255, 255, 0.7);
        transform: scale(1.1);
    }
}

/* 플로팅 주사위 버튼 */
.floating-dice-btn {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 4px solid white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    transition: all 0.3s;
}

.floating-dice-btn:active {
    transform: translateX(-50%) scale(0.9);
}

.floating-dice-btn:disabled {
    opacity: 0.5;
    background: #999;
}

.dice-icon {
    font-size: 48px;
    margin-bottom: 5px;
    animation: dice-bounce 1s infinite;
}

.dice-text {
    color: white;
    font-size: 13px;
    font-weight: bold;
}

@keyframes dice-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* 주사위 애니메이션 */
.dice-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.dice-container {
    display: flex;
    align-items: center;
    gap: 20px;
    animation: dice-container-appear 0.3s ease-out;
}

.dice-flying {
    width: 80px;
    height: 80px;
    background: white;
    border: 4px solid #333;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    animation: dice-roll 1s ease-out;
}

.dice-plus {
    font-size: 36px;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: plus-fade-in 0.5s ease-out 0.5s both;
}

.dice-total {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
    animation: total-appear 0.5s ease-out 0.8s both;
}

.total-label,
.total-unit {
    color: rgba(255, 255, 255, 0.9);
    font-size: 18px;
    font-weight: 600;
}

.total-number {
    color: white;
    font-size: 48px;
    font-weight: bold;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    animation: number-pulse 0.6s ease-in-out 1s;
}

@keyframes dice-container-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes plus-fade-in {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes total-appear {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes number-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: #ffd700;
    }
}

.dice-dots {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    padding: 8px;
    gap: 4px;
}

.dice-dots::before,
.dice-dots::after,
.dice-dot {
    content: '';
    width: 12px;
    height: 12px;
    background: #333;
    border-radius: 50%;
}

/* 주사위 1 */
[data-value="1"] .dice-dots::before {
    grid-area: 2 / 2;
}

/* 주사위 2 */
[data-value="2"] .dice-dots::before {
    grid-area: 1 / 3;
}
[data-value="2"] .dice-dots::after {
    grid-area: 3 / 1;
}

/* 주사위 3 */
[data-value="3"] .dice-dots::before {
    grid-area: 1 / 3;
}
[data-value="3"] .dice-dots::after {
    grid-area: 2 / 2;
}
[data-value="3"] .dice-dots {
    position: relative;
}
[data-value="3"] .dice-dots .dice-dot:nth-child(1) {
    grid-area: 3 / 1;
}

/* 주사위 4 */
[data-value="4"] .dice-dots::before {
    grid-area: 1 / 1;
}
[data-value="4"] .dice-dots::after {
    grid-area: 1 / 3;
}
[data-value="4"] .dice-dots .dice-dot:nth-child(1) {
    grid-area: 3 / 1;
}
[data-value="4"] .dice-dots .dice-dot:nth-child(2) {
    grid-area: 3 / 3;
}

/* 주사위 5 */
[data-value="5"] .dice-dots::before {
    grid-area: 1 / 1;
}
[data-value="5"] .dice-dots::after {
    grid-area: 1 / 3;
}
[data-value="5"] .dice-dots .dice-dot:nth-child(1) {
    grid-area: 2 / 2;
}
[data-value="5"] .dice-dots .dice-dot:nth-child(2) {
    grid-area: 3 / 1;
}
[data-value="5"] .dice-dots .dice-dot:nth-child(3) {
    grid-area: 3 / 3;
}

/* 주사위 6 */
[data-value="6"] .dice-dots::before {
    grid-area: 1 / 1;
}
[data-value="6"] .dice-dots::after {
    grid-area: 1 / 3;
}
[data-value="6"] .dice-dots .dice-dot:nth-child(1) {
    grid-area: 2 / 1;
}
[data-value="6"] .dice-dots .dice-dot:nth-child(2) {
    grid-area: 2 / 3;
}
[data-value="6"] .dice-dots .dice-dot:nth-child(3) {
    grid-area: 3 / 1;
}
[data-value="6"] .dice-dots .dice-dot:nth-child(4) {
    grid-area: 3 / 3;
}

@keyframes dice-roll {
    0% {
        transform: translateY(-200px) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: translateY(-50px) rotate(360deg);
        opacity: 1;
    }
    100% {
        transform: translateY(0) rotate(720deg);
        opacity: 1;
    }
}

/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: modal-fade-in 0.3s;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    padding: 30px 20px;
    border-radius: 20px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: modal-slide-up 0.3s;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes modal-slide-up {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 22px;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 20px;
}

.modal-content p {
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.5;
    color: #666;
}

#property-info,
#build-info,
#rent-info,
#modal-message {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: left;
    line-height: 1.8;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
}

/* 플레이어 선택 */
.player-select {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.player-count-btn {
    padding: 20px 10px;
    font-size: 18px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

.player-count-btn:active {
    background: #5568d3;
    transform: scale(0.95);
}

/* 플레이어 리스트 */
#players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.player-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid;
}

.player-card.active {
    background: #e6fffa;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.player-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-card-indicator {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.player-card-info {
    text-align: left;
}

.player-name {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 3px;
}

.player-properties {
    font-size: 12px;
    color: #666;
}

.player-money {
    font-size: 16px;
    font-weight: bold;
    color: #667eea;
}

/* 버튼 스타일 */
button {
    padding: 14px 20px;
    font-size: 16px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    touch-action: manipulation;
    min-height: 48px;
}

button:active:not(:disabled) {
    transform: scale(0.95);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-info {
    background: #4299e1;
    color: white;
}

.btn-secondary {
    background: #718096;
    color: white;
}

/* 색상 그룹 */
.color-brown { background: #8b4513; }
.color-skyblue { background: #87ceeb; }
.color-pink { background: #ff69b4; }
.color-orange { background: #ffa500; }
.color-red { background: #ff0000; }
.color-yellow { background: #ffff00; }
.color-green { background: #00ff00; }
.color-blue { background: #0000ff; }

/* 태블릿 */
@media (min-width: 600px) {
    .game-board {
        max-width: min(600px, 100vh - 150px);
    }

    .cell {
        font-size: 9px;
    }

    .cell-price {
        font-size: 7px;
    }

    .player-token {
        width: 16px;
        height: 16px;
    }

    .owner-indicator {
        width: 10px;
        height: 10px;
    }

    .building {
        width: 6px;
        height: 6px;
    }

    .floating-dice-btn {
        width: 140px;
        height: 140px;
    }

    .dice-icon {
        font-size: 56px;
    }

    .dice-text {
        font-size: 15px;
    }
}

/* 데스크탑 - 여전히 세로 모드 유지 */
@media (min-width: 1024px) {
    body {
        padding: 20px;
    }

    .container {
        max-width: 800px;
        margin: 0 auto;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 20px;
    }

    .game-board {
        max-width: min(700px, 100vh - 200px);
    }

    .cell {
        font-size: 10px;
    }

    .cell.corner {
        font-size: 12px;
    }

    .cell-price {
        font-size: 8px;
    }

    .cell-color {
        height: 12px;
    }

    .owner-indicator {
        width: 12px;
        height: 12px;
        border: 2px solid white;
    }

    .building {
        width: 8px;
        height: 8px;
    }

    .player-token {
        width: 18px;
        height: 18px;
    }

    .floating-dice-btn:hover {
        transform: translateX(-50%) scale(1.05);
    }

    .floating-dice-btn:active {
        transform: translateX(-50%) scale(0.95);
    }

    .info-btn:hover {
        background: #f0f0f0;
    }

    button:hover:not(:disabled) {
        filter: brightness(1.1);
    }

    .player-count-btn:hover {
        background: #5568d3;
        transform: scale(1.05);
    }

    .player-count-btn:active {
        transform: scale(0.95);
    }
}

/* 작은 화면 */
@media (max-width: 360px) {
    .cell {
        font-size: 6px;
    }

    .cell-price {
        font-size: 5px;
    }

    .floating-dice-btn {
        width: 100px;
        height: 100px;
        bottom: 20px;
    }

    .dice-icon {
        font-size: 40px;
    }

    .dice-text {
        font-size: 11px;
    }

    .modal-content {
        padding: 20px 15px;
    }

    button {
        font-size: 14px;
        padding: 12px 16px;
    }

    .dice-flying {
        width: 60px;
        height: 60px;
    }

    .dice-container {
        gap: 15px;
    }

    .dice-plus {
        font-size: 24px;
    }

    .dice-total {
        padding: 10px 20px;
        gap: 8px;
    }

    .total-label,
    .total-unit {
        font-size: 14px;
    }

    .total-number {
        font-size: 36px;
    }
}

/* iOS Safari 최적화 */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
    }

    .container {
        height: -webkit-fill-available;
    }
}

/* 터치 피드백 */
.cell:active {
    opacity: 0.8;
}

/* 스크롤바 숨기기 */
.modal-content::-webkit-scrollbar {
    width: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* 온라인 게임 UI */
.mode-select {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 10px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 30px 20px;
    background: white;
    border: 3px solid #667eea;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: #f0f4ff;
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.mode-btn:active {
    transform: translateY(-2px);
}

.mode-icon {
    font-size: 48px;
}

.mode-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.mode-desc {
    font-size: 13px;
    color: #666;
}

.online-select {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.online-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.online-btn:hover {
    background: #f0f4ff;
    border-color: #5568d3;
}

.online-btn:active {
    transform: scale(0.98);
}

.online-icon {
    font-size: 32px;
}

.online-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    flex: 1;
    text-align: left;
}

.back-btn {
    margin-top: 15px;
    width: 100%;
}

.room-code-display {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 20px 0;
}

.room-code {
    flex: 1;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 2px;
    color: #667eea;
    border: 2px solid #667eea;
    font-family: 'Courier New', monospace;
}

.room-input {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #667eea;
    border-radius: 12px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 20px 0;
}

.room-input:focus {
    outline: none;
    border-color: #5568d3;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.waiting-players {
    margin: 20px 0;
}

.waiting-players h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #333;
}

#waiting-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 60px;
}

.waiting-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid;
}

.waiting-player-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.waiting-player-name {
    flex: 1;
    font-weight: 600;
    color: #333;
}

.waiting-player-role {
    font-size: 12px;
    color: #666;
    background: #e0e0e0;
    padding: 4px 8px;
    border-radius: 12px;
}

@media (max-width: 600px) {
    .mode-select {
        grid-template-columns: 1fr;
    }

    .mode-btn {
        padding: 25px 15px;
    }

    .mode-icon {
        font-size: 40px;
    }

    .room-code {
        font-size: 20px;
        padding: 15px;
    }
}
