/* レノルーム: シンプル・ビジュアル重視スタイル */
:root {
    --room-bg: #fff8fa;
    --room-surface: #ffffff;
    --room-border: #eed8e1;
    --room-accent: #c9567d;
    --room-accent-soft: #fce8ef;
    --room-text: #3d2832;
    --room-subtext: #846572;
    --cast-accent: #d96b43;
}

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

html, body {
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #fff9fb 0%, #f8edf2 100%);
    color: var(--room-text);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
    overscroll-behavior-y: contain;
    user-select: none;
}

.game-title-accessible {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.room-app {
    max-width: 460px;
    margin: 0 auto;
    padding: 4px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* =========================
   上半分：お部屋ビュー
   ========================= */
.room-viewport {
    position: relative;
    background: #fff;
    border-radius: 18px;
    border: 1.5px solid var(--room-border);
    box-shadow: 0 6px 18px rgba(130, 68, 92, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* お部屋内上部ミニマルHUD */
.room-hud {
    position: absolute;
    top: 7px;
    left: 8px;
    right: 8px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.room-hud > * {
    pointer-events: auto;
}

.hud-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(220, 185, 198, 0.7);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
    color: var(--room-text);
    box-shadow: 0 2px 8px rgba(60, 30, 45, 0.07);
}

.hud-cast-btn {
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.12s ease;
}

.hud-cast-btn:active {
    transform: scale(0.95);
}

.hud-cast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cast-accent);
}

.hud-stats {
    display: flex;
    align-items: center;
    gap: 5px;
}

.hud-coin strong {
    color: #b57300;
    font-variant-numeric: tabular-nums;
}

.hud-streak strong {
    color: #d44d5c;
}

.hud-icon-btn {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    border: 1px solid rgba(220, 185, 198, 0.8);
    background: rgba(255, 255, 255, 0.88);
    color: var(--room-subtext);
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

/* 箱庭ステージ */
.room-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 400 / 200;
    max-height: 220px;
    overflow: hidden;
}

.room-svg-layer {
    width: 100%;
    height: 100%;
}

.room-svg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.room-part {
    cursor: pointer;
    transition: filter 0.15s ease;
}

.room-part:active {
    filter: brightness(1.08) drop-shadow(0 0 6px rgba(255, 255, 255, 0.85));
}

/* お部屋の中の彼 */
.room-cast-figure {
    position: absolute;
    right: 10%;
    bottom: 6px;
    width: 86px;
    height: 86px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 4;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.room-cast-figure:active,
.room-cast-figure.is-bouncing {
    transform: translateY(-5px) scale(1.06);
}

.room-cast-figure img {
    width: 84px;
    height: 84px;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(45, 20, 35, 0.26));
}

.cast-heart-fx {
    position: absolute;
    top: -8px;
    right: 4px;
    color: #ff4d79;
    font-size: 18px;
    opacity: 0;
    pointer-events: none;
}

.cast-heart-fx.is-pop {
    animation: heartPop 0.7s ease forwards;
}

@keyframes heartPop {
    0% { opacity: 0; transform: translateY(6px) scale(0.6); }
    35% { opacity: 1; transform: translateY(-6px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-18px) scale(0.95); }
}

.room-toast {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    background: rgba(45, 25, 36, 0.82);
    backdrop-filter: blur(4px);
    color: #fff9e6;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    z-index: 7;
    white-space: nowrap;
}

/* シンプルな1行会話バー */
.speech-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff9fb;
    border-top: 1px solid #f3e2e9;
    min-height: 34px;
}

.speech-dot {
    color: var(--cast-accent);
    font-size: 12px;
    flex-shrink: 0;
}

.speech-text {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    color: var(--room-text);
    font-weight: 600;
    flex: 1;
}

/* =========================
   モード切り替えタブ
   ========================= */
.mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    background: #f3e4eb;
    padding: 3px;
    border-radius: 13px;
}

.mode-tab {
    position: relative;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--room-subtext);
    border-radius: 10px;
    padding: 6px 8px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mode-tab.is-active {
    background: #fff;
    color: var(--room-accent);
    box-shadow: 0 2px 6px rgba(120, 50, 80, 0.12);
}

.tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff4d79;
}

/* =========================
   下半分①：トライピークス・ソリティア
   ========================= */
.panel-view {
    background: #fff;
    border-radius: 18px;
    border: 1.5px solid var(--room-border);
    padding: 8px;
    box-shadow: 0 6px 18px rgba(130, 68, 92, 0.06);
}

/* 18枚ピラミッド盤面 */
.tableau-wrap {
    position: relative;
    background: radial-gradient(circle at 50% 35%, #fff6f9 0%, #f4e4ec 100%);
    border-radius: 14px;
    border: 1px solid #edd6e1;
    height: 192px;
    padding: 8px 4px;
    overflow: hidden;
}

.combo-pill {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 8;
    font-size: 11px;
    font-weight: 900;
    padding: 2px 9px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff9a3c 0%, #e8507a 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(232, 80, 122, 0.28);
}

.tableau-board {
    position: relative;
    width: 100%;
    height: 100%;
}

.playing-card {
    position: absolute;
    width: 10.6%;
    height: 64px;
    left: calc(1.2% + var(--col, 0) * 10.85%);
    top: calc(6px + var(--row, 0) * 53px);
    border-radius: 9px;
    border: 1.5px solid #dcc5d0;
    background: #ffffff;
    box-shadow: 0 3px 7px rgba(60, 28, 42, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 2px;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.playing-card[data-row="0"] { z-index: 1; }
.playing-card[data-row="1"] { z-index: 2; }
.playing-card[data-row="2"] { z-index: 3; }

.playing-card.is-facedown {
    background: linear-gradient(145deg, #e89bb5 0%, #d47b99 100%);
    border-color: #fff;
    cursor: default;
}

.playing-card.is-facedown::after {
    content: "✿";
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
}

.playing-card.is-playable {
    border-color: #f0982b;
    box-shadow: 0 0 0 2.5px rgba(255, 200, 80, 0.52), 0 4px 10px rgba(184, 67, 107, 0.18);
    transform: translateY(-2px);
}

.playing-card.is-playable:active {
    transform: scale(0.92);
}

.playing-card[data-color="red"] {
    color: #d63858;
}

.playing-card[data-color="black"] {
    color: #2f2636;
}

.playing-card[data-color="gold"] {
    color: #b87a00;
    background: linear-gradient(160deg, #fffdf0 0%, #ffecb3 100%);
    border-color: #e0a82e;
}

.card-peak-crown,
.card-heart-badge {
    position: absolute;
    top: -5px;
    right: -4px;
    font-size: 9.5px;
    line-height: 1;
    border-radius: 99px;
    padding: 1px 3px;
}

.card-peak-crown {
    background: #fff4cc;
    border: 1px solid #e2b949;
}

.card-heart-badge {
    color: #fff;
    background: #e84c78;
    border: 1px solid #fff;
}

.card-rank {
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

.card-suit {
    font-size: 14px;
    line-height: 1;
}

.card-coin-pop {
    position: absolute;
    z-index: 9;
    pointer-events: none;
    font-size: 12px;
    font-weight: 900;
    color: #b86b00;
    background: rgba(255, 250, 224, 0.95);
    border: 1px solid #e6b84d;
    border-radius: 99px;
    padding: 1px 7px;
    transform: translate(-50%, 0);
    animation: coinFloatUp 0.7s ease-out forwards;
}

@keyframes coinFloatUp {
    0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); }
    25% { opacity: 1; transform: translate(-50%, -4px) scale(1.05); }
    100% { opacity: 0; transform: translate(-50%, -22px) scale(0.95); }
}

/* ラウンド終了オーバーレイ */
.round-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(45, 24, 34, 0.65);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.round-overlay[hidden] {
    display: none !important;
}

.round-card {
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    text-align: center;
    width: 100%;
    max-width: 280px;
    /* Long furniture goals and rescue actions must stay reachable in the 192px board. */
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.round-badge {
    display: inline-block;
    margin: 0 0 4px;
    padding: 2px 10px;
    border-radius: 99px;
    background: #ffe8ef;
    color: #c94672;
    font-size: 11px;
    font-weight: 800;
}

.round-title {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 900;
    color: #b57300;
}

.round-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.btn-primary, .btn-secondary, .btn-rescue {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 800;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, #d65b84 0%, #b8436b 100%);
    color: #fff;
}

.btn-secondary {
    background: #f5e6ed;
    color: #7a3e54;
}

.btn-rescue {
    background: linear-gradient(135deg, #f3a833 0%, #d97b16 100%);
    color: #fff;
    width: 100%;
}

/* 下部：山札・手札・アイコン操作バー */
.solitaire-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.stock-pile-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.stock-pile-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.stock-card-stack {
    width: 44px;
    height: 54px;
    border-radius: 9px;
    background: linear-gradient(145deg, #d96b94 0%, #b54871 100%);
    border: 2px solid #fff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 3px 0 #e2c2d0, 0 3px 8px rgba(80, 30, 50, 0.16);
}

.stock-card-stack strong {
    font-size: 16px;
    font-weight: 900;
}

/* 現在の手札(Waste) */
.waste-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fdf6f9;
    border: 1.5px solid #edd6e1;
    border-radius: 13px;
    padding: 4px 12px 4px 6px;
}

.playing-card.is-waste {
    position: static;
    width: 42px;
    height: 54px;
    cursor: default;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(80, 30, 50, 0.12);
}

.waste-hint {
    font-size: 13px;
    font-weight: 800;
    color: var(--room-accent);
    letter-spacing: 0.02em;
}

/* アイコンお助けボタン */
.helper-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.helper-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border: 1.5px solid #e8d0db;
    background: #fff;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
}

.helper-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.helper-btn:disabled {
    opacity: 0.38;
    cursor: default;
}

.helper-btn.is-wild {
    background: #fff9e6;
    border-color: #ebd083;
    color: #b87a00;
}

.helper-icon {
    font-size: 17px;
    line-height: 1;
}

.helper-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e09b1b;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 17px;
    height: 17px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 1.5px solid #fff;
}

/* =========================
   下半分②：模様替え＆ショップ
   ========================= */
.series-coord-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 7px;
}

.series-pill {
    border: 1px solid #ead4de;
    background: #fdf7fa;
    color: var(--room-text);
    border-radius: 10px;
    padding: 5px 4px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
}

.series-pill:active {
    transform: scale(0.95);
}

.category-strip {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 7px;
    scrollbar-width: none;
}

.category-strip::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    border: 1px solid #ead4de;
    background: #fff;
    color: var(--room-subtext);
    border-radius: 999px;
    padding: 5px 11px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}

.cat-btn.is-active {
    background: var(--room-accent);
    color: #fff;
    border-color: var(--room-accent);
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.item-card {
    border: 1.5px solid #edd8e2;
    border-radius: 13px;
    padding: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.item-card:active {
    transform: scale(0.97);
}

.item-card.is-equipped {
    border-color: var(--room-accent);
    background: #fff5f8;
}

.item-left {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.item-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.item-name {
    font-size: 12px;
    font-weight: 800;
    color: var(--room-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-status {
    font-size: 10.5px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 99px;
    flex-shrink: 0;
}

.item-status.is-equipped {
    background: var(--room-accent);
    color: #fff;
}

.item-status.is-owned {
    background: #f2e8ee;
    color: var(--room-subtext);
}

.item-status.is-affordable {
    background: #ffefc2;
    color: #8a5600;
    border: 1px solid #e6b84d;
}

.item-status.is-locked {
    background: #f5f0f2;
    color: #967d86;
}

/* =========================
   下半分③：彼を招く（キャスト選択）
   ========================= */
.cast-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.cast-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 13px;
    border: 1.5px solid #edd8e2;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.cast-card.is-selected {
    border-color: var(--room-accent);
    background: #fff4f8;
}

.cast-card-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cast-card img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: #fceef3;
    border: 1.5px solid #e6c3d0;
    flex-shrink: 0;
}

.cast-name {
    font-size: 13px;
    font-weight: 800;
    color: var(--room-text);
}

.cast-check {
    font-size: 12px;
    font-weight: 900;
    color: var(--room-accent);
}

/* ダイアログ */
.room-dialog {
    border: none;
    border-radius: 16px;
    padding: 0;
    max-width: 340px;
    width: calc(100% - 24px);
    box-shadow: 0 12px 32px rgba(45, 20, 35, 0.25);
}

.room-dialog::backdrop {
    background: rgba(40, 20, 30, 0.5);
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-bottom: 1px solid #f0dde5;
}

.dialog-head h2 {
    margin: 0;
    font-size: 14px;
}

.dialog-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: #f5e6ed;
    color: var(--room-text);
    font-size: 15px;
    cursor: pointer;
}

.dialog-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-block h3 {
    margin: 0 0 3px;
    font-size: 12.5px;
    color: var(--room-accent);
}

.help-block p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--room-text);
}

/* Keep card comparison and helper actions within narrow portrait screens. */
.solitaire-controls {
    display: grid;
    grid-template-columns: 44px 70px minmax(0, 1fr);
    gap: 6px;
}
.waste-slot {
    flex-direction: column;
    gap: 3px;
    padding: 3px 2px;
    min-width: 0;
}
.waste-hint { font-size: 11px; white-space: nowrap; letter-spacing: 0; }
.helper-actions { justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.helper-btn { width: 44px; height: 44px; flex-shrink: 0; }
.playing-card .card-rank { font-size: 19px; }
.playing-card .card-suit { font-size: 12px; }
.playing-card:not(.is-waste) { justify-content: flex-start; padding-top: 6px; }
.round-actions > button { max-width: 100%; overflow-wrap: anywhere; }

.deco-preview[hidden] { display: none; }
.deco-preview {
    margin-bottom: 8px;
    padding: 8px;
    border: 1px solid var(--room-accent);
    border-radius: 12px;
    background: var(--room-accent-soft);
}
.deco-preview p { margin: 0 0 6px; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.deco-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.deco-preview-actions button { min-height: 44px; max-width: 100%; overflow-wrap: anywhere; }
.deco-preview-actions button:disabled { opacity: 0.55; cursor: default; }
.item-card { min-width: 0; flex-wrap: wrap; }
.item-name { overflow-wrap: anywhere; }
.item-status { margin-left: auto; }
.item-card.is-preview { outline: 2px solid var(--room-accent); outline-offset: -3px; }
.room-part.is-preview { filter: drop-shadow(0 0 2px var(--room-accent)); }

@media (max-height: 740px) and (max-width: 540px) {
    .room-app[data-mode="solitaire"] .room-stage {
        aspect-ratio: auto;
        height: clamp(128px, 22vh, 160px);
    }
}
@media (prefers-reduced-motion: reduce) {
    .room-app *, .room-app *::before, .room-app *::after {
        animation: none !important;
        transition: none !important;
    }
}
