/* Honeycomb Layout - Column-based approach */
:root {
    --offset-coefficient: 27px; /* この値を変更して全体の間隔を調整 */
}

.honeycomb {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px;
    gap: 0px;
}

.hex-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: -17px;
}

.hex-column:first-child {
    margin-left: 0px;
}

/* Distance-based offset from center column (5th column) */
/* Formula: distance from center × --offset-coefficient */
.hex-column:nth-child(1) { transform: translateY(calc(4 * var(--offset-coefficient))); }  /* 距離4 */
.hex-column:nth-child(2) { transform: translateY(calc(3 * var(--offset-coefficient))); }  /* 距離3 */
.hex-column:nth-child(3) { transform: translateY(calc(2 * var(--offset-coefficient))); }  /* 距離2 */
.hex-column:nth-child(4) { transform: translateY(calc(1 * var(--offset-coefficient))); }  /* 距離1 */
.hex-column:nth-child(5) { transform: translateY(0px); }                                   /* 中央列 = 0 */
.hex-column:nth-child(6) { transform: translateY(calc(1 * var(--offset-coefficient))); }  /* 距離1 */
.hex-column:nth-child(7) { transform: translateY(calc(2 * var(--offset-coefficient))); }  /* 距離2 */
.hex-column:nth-child(8) { transform: translateY(calc(3 * var(--offset-coefficient))); }  /* 距離3 */
.hex-column:nth-child(9) { transform: translateY(calc(4 * var(--offset-coefficient))); }  /* 距離4 */

.hex {
    width: 60px;
    height: 52px;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s;
}

.hex:hover {
    background: linear-gradient(135deg, #8b5cf6, #c084fc);
    transform: scale(1.05);
}

.hex.valid-move {
    background: linear-gradient(135deg, #9333ea, #d946ef);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Stone styles */
.stone {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.stone-white {
    background: radial-gradient(circle at 30% 30%, #ffffff, #d1d5db);
    border: 2px solid #9ca3af;
}

.stone-black {
    background: radial-gradient(circle at 30% 30%, #1e3a8a, #0f172a);
    border: 2px solid #0c1d3d;
}

.valid-indicator {
    width: 15px;
    height: 12px;
    background: #ec4899;
    border-radius: 50%;
    pointer-events: none;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: linear-gradient(135deg, #1f2937, #374151);
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid #7c3aed;
}

.mode-button {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    color: white;
    width: 100%;
    margin-bottom: 12px;
}

.mode-button:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #8b5cf6, #c084fc);
}

.hidden {
    display: none !important;
}

/* Language selection buttons */
.lang-button {
    background: linear-gradient(135deg, #374151, #4b5563);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    color: white;
}

.lang-button:hover {
    background: linear-gradient(135deg, #4b5563, #6b7280);
    transform: scale(1.05);
}

.lang-button.active {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    border-color: #c084fc;
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .hex:hover {
        transform: none;
    }
    
    .mode-button, .share-button, .lang-button {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    /* Mobile Phones - デスクトップ設定をベースに比例縮小 */
    :root {
        --offset-coefficient: 22px; /* デスクトップ27px × 0.82 ≈ 22px */
    }
    
    .honeycomb {
        padding: 25px; /* デスクトップ30px × 0.82 ≈ 25px */
        transform: scale(0.82); /* 適切なスケール */
        transform-origin: center top;
    }
    
    .hex {
        width: 49px; /* デスクトップ60px × 0.82 ≈ 49px */
        height: 43px; /* デスクトップ52px × 0.82 ≈ 43px */
    }
    
    .stone {
        width: 34px; /* デスクトップ42px × 0.82 ≈ 34px */
        height: 34px;
    }
    
    .hex-column {
        margin-left: -14px; /* デスクトップ-17px × 0.82 ≈ -14px */
        gap: 1px; /* 2px → 1px に縮小 */
    }
    
    .valid-indicator {
        width: 12px;
        height: 10px;
    }
    
    /* UI adjustments */
    h1 {
        font-size: 1.8rem !important;
    }
    
    .mode-button {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .share-button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Player container height adjustment for mobile */
    #player1-container, #player2-container {
        min-height: 48px; /* さらに小さく */
        padding: 6px !important; /* パディングをより小さく */
    }
    
    #player1-container .font-semibold, #player2-container .font-semibold {
        font-size: 0.75rem; /* テキストをより小さく */
        line-height: 1.1; /* 行間をタイトに */
    }
    
    #player1-container .text-right, #player2-container .text-right {
        font-size: 0.75rem; /* スコア部分も同じサイズ */
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    /* Tablets */
    :root {
        --offset-coefficient: 24px;
    }
    
    .honeycomb {
        padding: 20px;
        transform: scale(0.9);
        transform-origin: center top;
    }
    
    .hex {
        width: 54px;
        height: 47px;
    }
    
    .stone {
        width: 38px;
        height: 38px;
    }
    
    .hex-column {
        margin-left: -15px;
    }
}

@media (min-width: 1600px) {
    /* Large Desktop */
    :root {
        --offset-coefficient: 29px; /* 30px → 29px にさらに縮小 */
    }
    
    .honeycomb {
        padding: 40px;
        transform: scale(1.1);
        transform-origin: center;
    }
    
    .hex {
        width: 66px;
        height: 57px;
    }
    
    .stone {
        width: 46px;
        height: 46px;
    }
    
    .hex-column {
        margin-left: -18px;
        gap: 1px; /* 縦隙間を1px小さく */
    }
}

/* SNS Share buttons */
.share-button {
    background: linear-gradient(135deg, #059669, #10b981);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.share-button:hover {
    background: linear-gradient(135deg, #047857, #059669);
    transform: scale(1.02);
}

.share-copy-btn {
    background: linear-gradient(135deg, #7c2d12, #ea580c);
}

.share-copy-btn:hover {
    background: linear-gradient(135deg, #9a3412, #dc2626);
}

/* Player turn visibility */
.player-active {
    background: linear-gradient(135deg, #1e3a8a, #3730a3) !important;
    border-color: #60a5fa !important;
}

.player-active .font-semibold {
    color: #dbeafe !important;
}

.player-inactive {
    background: #374151 !important;
    border-color: transparent !important;
}

.player-inactive .font-semibold {
    color: #9ca3af !important;
}

/* Player container height consistency */
#player1-container, #player2-container {
    min-height: 60px; /* 高さをやや小さく */
    display: flex;
    align-items: center; /* 垂直中央寄せ */
}

#player1-container > div, #player2-container > div {
    width: 100%;
}

#player1-container .font-semibold, #player2-container .font-semibold {
    line-height: 1.2; /* 行間を調整 */
    text-align: left; /* プレイヤー名は左寄せ */
}

#player1-container .text-right, #player2-container .text-right {
    text-align: right !important; /* スコアは右寄せ */
}