/* 全体のスタイル */
body {
    margin: 0;
    padding: 0;
    font-family: 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background-color: #1a1a1a;
    color: #ffffff;
    min-height: 100vh;
}

/* 画面共通スタイル */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    background-color: #1a1a1a;
}

.hidden {
    display: none !important;
}

/* ゲーム開始画面 */
.menu {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 30px;
    align-items: center;
}

/* セッションID表示 */
#session-display {
    background-color: #333;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin: 20px 0;
    min-width: 450px;
}

.session-id-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
}

.session-id {
    font-size: 32px;
    font-weight: bold;
    color: #4CAF50;
    letter-spacing: 2px;
    font-family: monospace;
    background-color: #1a1a1a;
    padding: 10px 20px;
    border-radius: 5px;
    user-select: all;
}

.icon-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    color: #888;
    transition: all 0.3s ease;
}

.icon-button:hover {
    color: #4CAF50;
    transform: scale(1.1);
}

.waiting-text {
    color: #888;
    margin-top: 10px;
    font-style: italic;
}

.join-game {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    background-color: #4CAF50;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover:not(:disabled) {
    background-color: #45a049;
    transform: translateY(-2px);
}

button:disabled {
    background-color: #666;
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

button:disabled.waiting {
    background-color: #666;
    color: #ccc;
    position: relative;
    padding-right: 40px;
}

button:disabled.waiting::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    border: 2px solid #ccc;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

input[type="text"] {
    padding: 10px;
    font-size: 16px;
    border: 1px solid #666;
    border-radius: 5px;
    background-color: #333;
    color: white;
    min-width: 300px;
}

input[type="text"]:disabled {
    background-color: #222;
    color: #666;
    cursor: not-allowed;
}

/* 手牌選択画面 */
.timer {
    font-size: 24px;
    margin-bottom: 20px;
    color: #ff9800;
}

.dora-display {
    font-size: 36px;
    margin-bottom: 10px;
}

.dora-display .tile {
    font-size: 120px;
}

.tiles-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
    max-width: 1200px;
}

.tile-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background-color: #333;
    border-radius: 10px;
    min-height: 80px;
    justify-content: flex-start;
}

/* メインゲーム画面 */
.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 20px;
    background-color: #333;
    padding: 10px 20px;
    border-radius: 5px;
    align-self: center;
}

.remaining-turns {
    font-size: 24px;
    color: #ff9800;
}

.game-board {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
}

.discard-pile {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 15px;
    background-color: #333;
    border-radius: 10px;
    min-height: 60px;
    justify-content: flex-start;
}

#selected-hand {
    background-color: #2d4d2d;
    border: 2px solid #4CAF50;
}

.game-controls {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* 麻雀牌のスタイル */
.tile {
    font-size: 80px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s, opacity 0.2s;
    background-color: #2d2d2d;
    color: #e0e0e0;
    border-radius: 5px;
    padding: 2px 4px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.2em;
}
@keyframes sparkle {
    0% {
        box-shadow: 0 0 4px rgba(214, 189, 151, 0.5),
                   0 0 8px rgba(214, 189, 151, 0.3);
        color: rgb(214, 189, 151);
    }
    50% {
        box-shadow: 0 0 8px rgba(214, 189, 151, 0.8),
                   0 0 16px rgba(214, 189, 151, 0.5);
        color: rgb(230, 205, 167);
    }
    100% {
        box-shadow: 0 0 4px rgba(214, 189, 151, 0.5),
                   0 0 8px rgba(214, 189, 151, 0.3);
        color: rgb(214, 189, 151);
    }
}

.dora-tile {
    color: rgb(214, 189, 151); /* ドラ牌を目立たせる */
    position: relative;
    animation: sparkle 2s infinite;
    text-shadow: 0 0 4px rgba(214, 189, 151, 0.3);
    z-index: 1;
}

.dora-tile::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: radial-gradient(circle at 50% 50%,
                              rgba(214, 189, 151, 0.2),
                              transparent 70%);
    z-index: -1;
    border-radius: 7px;
    opacity: 0.7;
}

.tile:hover {
    transform: translateY(-5px);
    opacity: 0.9;
}

/* エラーメッセージ */
#error-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ff4444;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 80%;
}

#error-message.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ゲーム状態表示 */
#game-status {
    font-size: 18px;
    color: #4CAF50;
}

/* 結果画面 */
#result-content {
    margin: 20px 0;
    padding: 30px;
    background-color: #333;
    border-radius: 5px;
    text-align: center;
}

.result-title {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 15px;
}

.result-title:has(+ .result-detail) {
    margin-bottom: 10px;
}

.result-detail {
    font-size: 18px;
    color: #aaa;
    line-height: 1.5;
}

#winning-hand {
    margin: 20px 0;
}

#yaku-list {
    margin: 20px 0;
    padding: 10px;
    background-color: #333;
    border-radius: 5px;
    text-align: left;
}

.yaku-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.yaku-name {
    color: #ff9800;
}

.han-value {
    color: #4CAF50;
}

/* 和了可能牌リスト */
/* メインゲーム画面のレイアウト調整 */
.game-board {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    align-self: flex-start;
}

#game-screen {
    padding-top: 10px;
    align-items: flex-start;
}

/* 手牌コントロール */
.hand-controls {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
    padding-right: 10px;
}

/* 待ち牌表示エリア */
#winning-tiles-display,
#playing-winning-tiles-display {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    max-width: 900px;
    max-height: 70vh;
    background-color: rgba(51, 51, 51, 0.95);
    border-radius: 10px;
    padding: 30px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#winning-tiles-display .close-button,
#playing-winning-tiles-display .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #666;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#winning-tiles-display .close-button:hover,
#playing-winning-tiles-display .close-button:hover {
    background-color: #ff4444;
    transform: scale(1.1);
}

#winning-tiles-display .winning-tiles-grid,
#playing-winning-tiles-display .winning-tiles-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

#winning-tiles-display .winning-tile-row,
#playing-winning-tiles-display .winning-tile-row {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background-color: #2d2d2d;
    border-radius: 8px;
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

#winning-tiles-display .winning-tile-row:hover,
#playing-winning-tiles-display .winning-tile-row:hover {
    background-color: #3d3d3d;
    transform: translateY(-2px);
}

#winning-tiles-display .tile-row,
#playing-winning-tiles-display .tile-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#winning-tiles-display .tile,
#playing-winning-tiles-display .tile {
    font-size: 60px;
    cursor: pointer;
    transition: transform 0.2s;
}

#winning-tiles-display .tile:hover,
#playing-winning-tiles-display .tile:hover {
    transform: scale(1.1);
}

#winning-tiles-display .yaku-info-container,
#playing-winning-tiles-display .yaku-info-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

#winning-tiles-display .yaku-names,
#playing-winning-tiles-display .yaku-names {
    font-size: 28px;
    color: #4CAF50;
    font-weight: bold;
}

#winning-tiles-display .yaku-values,
#playing-winning-tiles-display .yaku-values {
    font-size: 24px;
    color: #ff9800;
}

#winning-tiles-display .remaining-count,
#playing-winning-tiles-display .remaining-count {
    font-size: 20px;
    color: #888;
    margin-top: 5px;
}

#playing-winning-tiles-display .winning-tiles-header {
    font-size: 28px;
    color: #4CAF50;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

/* オーバーレイ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    display: none;
    pointer-events: none;
}

.overlay.visible {
    display: block;
}

/* トグルボタンのスタイル */
.toggle-button {
    background-color: #666;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-button:hover {
    background-color: #777;
}

.toggle-button.active {
    background-color: #4CAF50;
}

.toggle-button.active:hover {
    background-color: #45a049;
}

#winning-tiles-display .tile-info-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

#winning-tiles-display .tile {
    font-size: 60px;
    margin-right: 5px;
}

#winning-tiles-display .remaining-count {
    color: #4CAF50;
    font-weight: bold;
    background-color: rgba(76, 175, 80, 0.1);
    padding: 4px 8px;
    border-radius: 3px;
    min-width: 80px;
    text-align: center;
}

#winning-tiles-display .yaku-info-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

#winning-tiles-display .yaku-names {
    color: #ff9800;
    font-size: 16px;
}

#winning-tiles-display .dora-count {
    background-color: rgba(214, 189, 151, 0.2);
    color: rgb(214, 189, 151);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    display: inline-block;
    margin-top: 5px;
    text-align: center;
    animation: doraPulse 2s infinite;
}

@keyframes doraPulse {
    0% {
        box-shadow: 0 0 3px rgba(214, 189, 151, 0.3);
    }
    50% {
        box-shadow: 0 0 8px rgba(214, 189, 151, 0.6);
    }
    100% {
        box-shadow: 0 0 3px rgba(214, 189, 151, 0.3);
    }
}

#winning-tiles-display .yaku-values {
    color: #4CAF50;
    font-size: 14px;
}

/* 役表示 */
#yaku-display {
    margin-top: 10px;
    font-size: 18px;
    color: #ff9800;
    text-align: center;
    padding: 10px;
    background-color: rgba(255, 152, 0, 0.1);
    border-radius: 5px;
    margin-bottom: 20px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

#yaku-display:hover {
    background-color: rgba(255, 152, 0, 0.2);
}

#yaku-display::after {
    content: 'マウスを重ねると待ち牌一覧を表示';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#yaku-display:hover::after {
    opacity: 1;
}

/* コピー成功時のフィードバック */
.copy-feedback {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.copy-feedback.show {
    opacity: 1;
}

/* ボタングループ */
.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.button-group button {
    min-width: 150px;
}

.ron-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.ron-button {
    font-size: 48px;
    padding: 20px 60px;
    background: linear-gradient(45deg, #ff0000, #ff6b6b);
    border: none;
    border-radius: 15px;
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    animation: ronPulse 2s infinite;
    position: relative;
    overflow: hidden;
}

.ron-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transform: rotate(45deg);
    animation: ronShine 3s infinite;
}

@keyframes ronPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(255, 0, 0, 0.7);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    }
}

@keyframes ronShine {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) rotate(45deg);
    }
}

.ron-button:hover {
    background: linear-gradient(45deg, #ff6b6b, #ff0000);
    transform: scale(1.1);
    transition: transform 0.3s ease;
}

/* 自分のターン時のエフェクト */
@keyframes active-turn {
    0% {
        box-shadow: 0 0 5px rgba(76, 175, 80, 0.5),
                   0 0 10px rgba(76, 175, 80, 0.3);
    }
    50% {
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.8),
                   0 0 20px rgba(76, 175, 80, 0.5);
    }
    100% {
        box-shadow: 0 0 5px rgba(76, 175, 80, 0.5),
                   0 0 10px rgba(76, 175, 80, 0.3);
    }
}

.player-turn {
    animation: active-turn 2s infinite;
    border: 2px solid #4CAF50 !important;
    position: relative;
    z-index: 1;
}

.player-turn::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: radial-gradient(circle at 50% 50%,
                              rgba(76, 175, 80, 0.2),
                              transparent 70%);
    z-index: -1;
    border-radius: 7px;
    opacity: 0.7;
    pointer-events: none;
}

#playing-winning-tiles-display .tile-info-container {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
}

#playing-winning-tiles-display .remaining-count {
    color: #4CAF50;
    font-weight: bold;
    background-color: rgba(76, 175, 80, 0.1);
    padding: 8px 16px;
    border-radius: 5px;
    min-width: 100px;
    text-align: center;
    font-size: 24px;
}

.game-options {
    margin: 20px 0;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    width: 100%;
    max-width: 400px;
}

.option-item {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.option-item label {
    margin-bottom: 5px;
    font-weight: bold;
}

.option-item select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #333;
    width: 100%;
    margin-bottom: 5px;
}

.option-description {
    font-size: 0.8em;
    color: #aaa;
    margin-top: 3px;
}

.create-game-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.option-checkbox {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.option-checkbox input[type="checkbox"] {
    margin-right: 5px;
    cursor: pointer;
}

.option-checkbox label {
    font-size: 14px;
    color: #ccc;
    cursor: pointer;
}

.option-tooltip {
    position: absolute;
    bottom: -30px;
    left: 0;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 100;
}

.option-checkbox:hover .option-tooltip {
    opacity: 1;
    visibility: visible;
}

/* ヒントボタンとヒント表示のスタイル */
.tiles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tiles-header p {
    margin: 0;
}

.hint-button {
    background-color: #ff9800;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.hint-button:hover {
    background-color: #f57c00;
    transform: translateY(-2px);
}

.hint-button:disabled {
    background-color: #666;
    cursor: not-allowed;
    transform: none;
}

#hint-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 900px;
    max-height: 80vh;
    background-color: rgba(51, 51, 51, 0.95);
    border-radius: 10px;
    padding: 30px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#hint-display .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #666;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#hint-display .close-button:hover {
    background-color: #ff4444;
    transform: scale(1.1);
}

.hint-header {
    font-size: 28px;
    color: #ff9800;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

#hint-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.hint-item {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background-color: #2d2d2d;
    border-radius: 8px;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    cursor: pointer;
}

.hint-item:hover {
    background-color: #3d3d3d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.hint-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.hint-yaku {
    font-size: 18px;
    color: #4CAF50;
    font-weight: bold;
}

.hint-value {
    font-size: 16px;
    color: #ff9800;
}

.no-hint {
    text-align: center;
    padding: 30px;
    color: #888;
    font-size: 18px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin: 20px auto;
    max-width: 80%;
}

.hint-item .dora-count {
    background-color: rgba(214, 189, 151, 0.2);
    color: rgb(214, 189, 151);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    display: inline-block;
    margin-top: 5px;
    text-align: center;
    animation: doraPulse 2s infinite;
}

@keyframes doraPulse {
    0% {
        box-shadow: 0 0 3px rgba(214, 189, 151, 0.3);
    }
    50% {
        box-shadow: 0 0 8px rgba(214, 189, 151, 0.6);
    }
    100% {
        box-shadow: 0 0 3px rgba(214, 189, 151, 0.3);
    }
}

/* ヒント表示のスタイル更新 */
.hint-tiles-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.hint-section-label {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 5px;
}

.hint-waiting-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
}