/* =========================================
   1. ベース設定・ズーム防止
   ========================================= */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    background: #333;
    overflow: hidden;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
}

#app-container {
    width: 100vw;
    height: 100vh;
    max-width: 500px;
    background: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* =========================================
   2. ロード・カウントダウン
   ========================================= */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-wrapper {
    display: flex;
    gap: 15px;
}

.load-dot {
    width: 50px;
    height: 50px;
    animation: wave 1.2s infinite ease-in-out;
}

.load-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.load-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wave {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-20px);
    }
}

#countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 120px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    pointer-events: none;
}

/* =========================================
   3. レシート風リザルト
   ========================================= */
#result-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.receipt {
    background: #fff;
    width: 85%;
    max-width: 320px;
    padding: 30px 20px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    animation: receiptSlideIn 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes receiptSlideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.receipt::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 10px;
    background-image: linear-gradient(135deg, #fff 5px, transparent 0),
        linear-gradient(-135deg, #fff 5px, transparent 0);
    background-size: 10px 10px;
}

.receipt-header {
    text-align: center;
}

.receipt-title {
    font-size: 20px;
    font-weight: bold;
    margin: 0;
}

.receipt-line {
    border-top: 1px dashed #aaa;
    margin: 15px 0;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    font-size: 15px;
}

.receipt-total {
    display: flex;
    justify-content: space-between;
    font-size: 26px;
    font-weight: bold;
}

.receipt-exp-section {
    margin-top: 20px;
    background: #f9f9f9;
    padding: 12px;
    border-radius: 4px;
}

.exp-bar-container {
    width: 100%;
    height: 10px;
    background: #ddd;
    border-radius: 5px;
    overflow: hidden;
    margin: 8px 0;
}

#exp-bar-fill {
    height: 100%;
    background: #c6443e;
    width: 0%;
    transition: width 1.5s;
}

.receipt-close-btn {
    width: 100%;
    margin-top: 20px;
    background: #333;
    color: #fff;
    border: none;
    padding: 15px;
    border-radius: 50px;
    font-weight: bold;
}

/* =========================================
   4. ホーム画面・UI（左上：横並びお皿ライフ）
   ========================================= */
.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

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

.user-status-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.user-name-row {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

/* お皿を横に並べるライフゲージ */
.life-plate-horiz {
    display: flex;
    flex-direction: row;
    /* 横並び */
    align-items: center;
    gap: 0px;
    /* お皿を少し重ねる場合はマイナスにする */
}

.life-plate-unit {
    width: 50px;
    /* 横並びなので少し小さめに */
    height: 45px;
    background-image: url('./assets/Life_sara.png');
    background-size: contain;
    background-repeat: no-repeat;
    margin-right: -10px;
    /* 少し重ねて密度を出す */
    transition: opacity 0.3s, filter 0.3s;
}

.life-plate-unit.consumed {
    opacity: 0.2;
    filter: grayscale(1);
    /* 食べ終わった皿はグレーに */
}

.setting-icon {
    width: 60px;
    height: 60px;
    opacity: 0.5;
    cursor: pointer;
    margin-left: -10px;
    /* 数値を -10px, -15px と大きくすると左に動きます */
    margin-top: -10px;
    /* -10px などにすると、さらにお皿に食い込むように上がります */
}

.line-btn-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* メインビジュアル */
.main-visual {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.level-badge {
    background: #333;
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    margin-bottom: 15px;
}

.char-frame {
    width: 220px;
    height: 220px;
    background: #fffaf0;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 8px solid #f3e5f5;
}

#home-char-img {
    width: 85%;
    height: auto;
    object-fit: contain;
}

/* ボタン */
.main-action-btn {
    width: 100%;
    background: #c6443e;
    color: #fff;
    border: none;
    padding: 18px;
    border-radius: 50px;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 15px;
    box-shadow: 0 4px 0 #a0332e;
}

.sub-action-btn {
    width: 100%;
    background: #fff;
    color: #333;
    border: 2px solid #333;
    padding: 15px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: bold;
}

/* =========================================
   5. ゲーム画面UI
   ========================================= */
#score {
    font-size: 42px;
    font-weight: bold;
    color: #c6443e;
    text-align: center;
    display: block;
    width: 100%;
}

#game-canvas-container {
    flex-grow: 1;
    position: relative;
    background: #fffaf0;
    border-top: 2px solid #eee;
}

#timer-display {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 18px;
    border-radius: 25px;
    font-weight: bold;
    z-index: 100;
}

/* シャッフルボタンの押し心地 */
#shuffle-btn {
    transition: transform 0.05s, box-shadow 0.05s;
}

#shuffle-btn:active {
    transform: scale(0.9);
    box-shadow: 0 1px 0 #333;
    /* 影を小さくして沈んだように見せる */
    filter: brightness(0.9);
    /* 少し暗くして押した感を出す */
}

/* 操作パネル全体 */
#game-controls {
    height: 90px;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* 両端に配置 */
    padding: 0 25px;
    border-top: 2px solid #ddd;
}

/* クールタイム中のボタン（半透明 ＆ 押せない感） */
.control-btn.cooldown {
    opacity: 0.4;
    /* 半透明にする */
    filter: grayscale(1);
    /* 白黒にする（任意） */
    cursor: not-allowed;
    /* カーソルを禁止マークに（PC用） */
    box-shadow: none;
    /* 影を消して沈んだままにする */
    transform: translateY(2px);
}

/* クールタイム中の画像も少し暗く */
.control-btn.cooldown img {
    filter: brightness(0.5);
}

/* ボタンの共通スタイル（アイコン用） */
.control-btn {
    width: 60px;
    height: 60px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 15px;
    /* 少し角丸 */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 0 #333;
    cursor: pointer;
    padding: 0;
}

.control-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #333;
}

/* 設定アイコンとシャッフルアイコンの画像サイズ */
#game-setting-btn img,
.shuffle-icon-img {
    width: 70%;
    /* ボタンの枠に対して7割の大きさ */
    height: 70%;
    object-fit: contain;
    opacity: 0.8;
}

/* 中央のスペースは自動で広がる */
.control-center-spacer {
    flex-grow: 1;
}

/* =========================================
   6. 登録画面（名前入力）
   ========================================= */
#screen-register {
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* 画面中央に寄せる */
    align-items: center;
    text-align: center;
    background-color: #fffaf0;
    /* 少し和風な温かい白 */
}

.title-logo {
    font-size: 64px;
    font-weight: bold;
    color: #c6443e;
    /* しな丸レッド */
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

#screen-register p {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
}

#user-name-input {
    width: 80%;
    max-width: 300px;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 12px;
    text-align: center;
    outline: none;
    margin-bottom: 25px;
    transition: border-color 0.3s;
}

#user-name-input:focus {
    border-color: #c6443e;
    /* 入力中は赤く光る */
}

/* 登録画面のボタン幅を少し調整 */
#screen-register .main-action-btn {
    width: 80%;
    max-width: 300px;
}

/* =========================================
   7. その他の細かいスタイル調整
   ========================================= */
/* 設定モーダル共通 */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 6000;
}

.setting-content {
    background: #fff;
    width: 85%;
    max-width: 320px;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.setting-header h3 {
    margin: 0;
    color: #333;
    text-align: center;
    font-size: 20px;
}

.setting-body {
    margin-top: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 14px;
    color: #444;
}

#edit-user-name {
    width: 60%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* スイッチのデザイン */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #c6443e;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.danger span {
    color: #c6443e;
    font-weight: bold;
}

#reset-data-btn {
    background: #eee;
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
}

/* =========================================
   番付表（ランキング）のスタイル - 画面いっぱい修正版
   ========================================= */
#screen-ranking {
    width: 100%;
    height: 100%;
    padding: 0;
    /* 画面端の余白をゼロに */
    display: none;
    flex-direction: column;
    background: #fffaf0;
}

.ranking-header {
    width: 100%;
    padding: 30px 20px 10px;
    /* 上部に少し余裕を持たせる */
    background: #fff;
    text-align: center;
}

.title-logo.small {
    font-size: 32px;
    margin-bottom: 5px;
}

#ranking-list-container {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    padding: 0;
    /* リスト内の余白もゼロにして端まで広げる */
    background: #fffaf0;
    border: none;
    /* 枠線を消してスッキリさせる */
    border-radius: 0;
    /* 角丸をなくす */
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    /* 左右に20pxの余白、上下を広げてリッチに */
    border-bottom: 1px dashed #ddd;
    font-family: 'Consolas', monospace;
    background: rgba(255, 255, 255, 0.5);
    /* ほんのり白背景 */
}

.ranking-rank {
    width: 50px;
    font-weight: bold;
    color: #c6443e;
    font-size: 20px;
}

.ranking-name {
    flex-grow: 1;
    text-align: left;
    margin-left: 10px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-score {
    font-weight: bold;
    color: #c6443e;
    font-size: 18px;
}

/* 上位3名の装飾（より豪華に） */
.rank-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.15), transparent);
    border-left: 5px solid #ffd700;
}

.rank-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.15), transparent);
    border-left: 5px solid #c0c0c0;
}

.rank-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.15), transparent);
    border-left: 5px solid #cd7f32;
}

.ranking-footer {
    width: 100%;
    padding: 20px;
    background: #fff;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.05);
    /* 下から浮き上がって見えるように */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 「暖簾をくぐる」ボタンの幅調整 */
#back-to-home-btn {
    width: 90%;
    max-width: 300px;
}

/* LINEログインボタン */
.line-auth-btn {
    background-color: #06C755;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s;
}

.line-auth-btn:active {
    background-color: #05a346;
    transform: translateY(1px);
}

.line-auth-btn::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    /* LINEのアイコン画像をassetsに入れていれば背景指定、なければ文字だけでもOK */
    background-size: contain;
    background-repeat: no-repeat;
}