﻿/* style-ui_public.css - layout and UI components. */
body.theme-midnight { --bg-color: #0f172a; --table-bg: #1e293b; --card-bg: #f8fafc; --border-color: #38bdf8; --panel-bg: rgba(15, 23, 42, 0.6); --btn-secondary: #334155; }

/* Hide scrollbars */
.modal-scroll, #modalHistoryContent, .chat-messages, #roomsContainer { scrollbar-width: none; -ms-overflow-style: none; }
.modal-scroll::-webkit-scrollbar, #modalHistoryContent::-webkit-scrollbar, .chat-messages::-webkit-scrollbar, #roomsContainer::-webkit-scrollbar { display: none; width: 0; height: 0; }

.top-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 40px; width: 100%; position: absolute; top: 0; z-index: 100; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; white-space: nowrap; }

.center-content { width: 1000px; margin: 150px auto 0 auto; text-align: center; }
.lobby-title { font-size: 42px; margin-bottom: 30px; }
.auth-box { background: var(--panel-bg); border: 2px solid rgba(255,255,255,0.2); border-radius: 10px; padding: 30px; width: 500px; margin: 0 auto 30px auto; }
.auth-title { color: var(--border-color); margin-bottom: 20px; font-size: 24px; }
.auth-buttons { display: flex; gap: 10px; }
.auth-buttons > * { flex: 1; }
.user-info { margin-bottom: 20px; font-size: 18px; }
.room-list-box { background: var(--panel-bg); border: 2px solid rgba(255,255,255,0.2); border-radius: 10px; padding: 20px; width: 700px; margin: 0 auto; }
.room-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.room-header h3 { font-size: 24px; }

#roomsContainer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 270px; overflow-y: auto; padding-right: 6px; }
#roomsContainer > p:only-child { grid-column: 1 / -1; text-align: center; }
.room-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; padding: 8px 6px; margin: 0; font-size: 13px; text-align: center; min-width: 0; }
.room-item > div { font-size: 13px; word-break: break-word; line-height: 1.2; }
.room-item .ui-btn { padding: 4px 10px; font-size: 12px; height: 28px; margin: 0; }
.room-buttons { display: flex; flex-direction: row; gap: 4px; justify-content: center; }
.room-info { margin-top: 20px; background: var(--panel-bg); padding: 30px; border-radius: 10px; width: 700px; margin: 20px auto 0 auto; }
.player-list { list-style: none; margin: 20px 0; display: flex; flex-direction: column; justify-content: center; gap: 10px; font-size: 18px; }
.room-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }

/* ---------- MODAL FRAMEWORK (Variable Driven) ---------- */
.modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 2500; }

.modal-content {
  --m-bg: var(--table-bg, #154d20);
  --m-fg: #fff;
  --m-sub: #8eb395;
  --m-line: rgba(255,255,255,0.1);
  --m-ac: var(--border-color, #ffce00);
  position: relative;
  background: var(--m-bg);
  border: 1px solid var(--m-line);
  color: var(--m-fg);
  border-radius: 10px;
  padding: 22px 28px;
  width: 600px;
  max-height: 85vh;
  overflow: hidden;
  text-align: left;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--m-line); flex-shrink: 0; gap: 12px; }
.modal-title { color: var(--m-ac); font-size: 22px; font-weight: 600; letter-spacing: 0.3px; margin: 0; padding: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Red Hanko Close Button */
.modal-close { background: transparent; border: none; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.15s ease, filter 0.15s ease; flex-shrink: 0; }
.modal-close:hover { transform: scale(1.08) rotate(2deg); filter: brightness(1.1); }
.hanko { display: grid; place-items: center; width: 34px; height: 34px; background: #c8372d; color: #fff; font: 400 18px 'Hiragino Mincho ProN', 'Yu Mincho', Georgia, serif; border-radius: 4px; transform: rotate(-5deg); box-shadow: 0 2px 4px rgba(0,0,0,0.3); }

/* Modal sizes */
#scoreModal .modal-content { height: 800px; width: 960px; max-height: 800px; }
#leaderboardModal .modal-content { height: 800px; width: 960px; max-height: 800px; }
#profileModal .modal-content { height: 800px; width: 960px; max-height: 800px; }
#shopModal .modal-content { height: 680px; width: 840px; }
#settingsModal .modal-content { width: 520px; }
#swishModal .modal-content { width: 520px; }

#shopModal { justify-content: center; }
#cardBackPreviewModal { justify-content: flex-start; padding-left: 250px; align-items: center; pointer-events: none; z-index: 2600; }
#cardBackPreviewModal .modal-content { width: 200px; padding: 12px; gap: 10px; pointer-events: auto; display: flex; flex-direction: column; align-items: center; }
#cardBackPreviewModal .preview-title { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; margin: 0; color: var(--m-sub); font-weight: 600; }

.modal-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }

/* Tabs */
.tab-row { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--m-line); padding-bottom: 10px; flex-shrink: 0; }
.tab-btn { padding: 8px 16px; font-size: 14px; font-weight: 600; background: transparent; color: var(--m-sub); border: 1px solid transparent; border-radius: 5px; cursor: pointer; transition: all 0.15s; }
.tab-btn:hover { color: var(--m-fg); background: rgba(128,128,128,0.1); }
.tab-btn.active { background: var(--m-ac); color: #fff; border-color: var(--m-ac); }

/* Pagination */
.pagination-row { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 12px 0 2px 0; flex-shrink: 0; }
.pagination-row .pag-btn { padding: 6px 16px; font-size: 13px; font-weight: 600; background: transparent; color: var(--m-fg); border: 1px solid var(--m-line); border-radius: 5px; cursor: pointer; min-width: 90px; height: 34px; transition: all 0.15s; }
.pagination-row .pag-btn:hover:not(:disabled) { background: rgba(128,128,128,0.1); }
.pagination-row .pag-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination-row .pag-info { font-size: 13px; color: var(--m-sub); min-width: 90px; text-align: center; font-weight: 600; }

/* Stats & Lists */
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--m-line); font-size: 15px; }
.clickable-name { color: var(--m-ac); cursor: pointer; text-decoration: none; font-weight: 600; }
.clickable-name:hover { text-decoration: underline; }

/* History */
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-shrink: 0; gap: 10px; }
.history-filter { width: 240px; padding: 9px 14px; border-radius: 5px; border: 1px solid var(--m-line); background: rgba(128,128,128,0.1); color: var(--m-fg); font-size: 14px; margin: 0; }
.history-filter:focus { border-color: var(--m-ac); outline: none; }
#modalHistoryContent { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; }
.history-card { background: rgba(128,128,128,0.05); border: 1px solid var(--m-line); border-radius: 8px; padding: 14px 16px; }
.history-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.history-date { font-size: 13px; color: var(--m-sub); font-weight: 600; }
.history-winner-pill { font-size: 12px; color: var(--m-ac); background: rgba(128,128,128,0.1); border: 1px solid var(--m-line); padding: 3px 10px; border-radius: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.history-changes { display: flex; flex-direction: column; gap: 3px; }
.history-change-row { display: flex; justify-content: space-between; font-size: 13px; line-height: 1.5; }

/* Leaderboard */
.leaderboard-container { display: block; }
.lb-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--m-line); font-size: 16px; }
.lb-row:last-child { border-bottom: none; }
.lb-row-me { background: rgba(128,128,128,0.1); border-left: 3px solid var(--m-ac); padding-left: 15px; }
.lb-row-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.lb-row-left .clickable-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-rank { display: inline-block; min-width: 36px; color: var(--m-sub); font-weight: 600; font-size: 15px; text-align: center; }
.lb-medal { font-size: 26px; min-width: 36px; text-align: center; line-height: 1; }
.lb-you { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--m-ac); border: 1px solid var(--m-ac); padding: 2px 8px; border-radius: 9px; margin-left: 4px; white-space: nowrap; }

/* Profile */
.profile-title-badge { text-align: center; font-size: 13px; color: var(--m-ac); font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 14px; padding: 9px 16px; background: rgba(128,128,128,0.1); border: 1px solid var(--m-line); border-radius: 6px; }
.profile-section { background: rgba(128,128,128,0.05); border: 1px solid var(--m-line); border-radius: 8px; padding: 16px 20px; margin-bottom: 14px; }
.profile-section-title { color: var(--m-sub); font-size: 13px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--m-line); }
.profile-section .stat-row { border-bottom: 1px solid var(--m-line); padding: 9px 0; font-size: 15px; }
.profile-section .stat-row:last-child { border-bottom: none; }
.profile-record { display: flex; align-items: center; justify-content: center; gap: 36px; padding: 14px 0 12px 0; }
.profile-record-side { text-align: center; }
.profile-record-num { font-size: 34px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.profile-record-label { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--m-sub); margin-top: 5px; font-weight: 600; }
.profile-record-sep { width: 1px; height: 40px; background: var(--m-line); }

/* Swish */
.swish-panel { display: flex; flex-direction: column; gap: 12px; }
.swish-panel.hidden { display: none; }
.swish-form-card { background: rgba(128,128,128,0.05); border: 1px solid var(--m-line); border-radius: 7px; padding: 14px 16px; }
.swish-form-label { font-size: 11px; color: var(--m-sub); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 9px; font-weight: 600; }
.swish-form-card .swish-input, .swish-form-card .swish-receiver-input { margin-bottom: 0; font-size: 15px; padding: 11px 14px; background: rgba(128,128,128,0.1); border: 1px solid var(--m-line); color: var(--m-fg); }
.swish-input-amount { font-size: 26px !important; text-align: center; font-weight: 600; }
.swish-submit-btn { height: 48px !important; font-size: 15px !important; margin-top: 4px; font-weight: 600; letter-spacing: 0.5px; }
.swish-history-card { background: rgba(128,128,128,0.05); border: 1px solid var(--m-line); border-radius: 7px; padding: 12px 16px; margin-bottom: 10px; }
.swish-history-card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 15px; margin-bottom: 4px; }
.swish-history-amount { color: var(--m-ac); font-weight: 600; font-size: 16px; white-space: nowrap; }
.swish-history-date { font-size: 12px; color: var(--m-sub); }

/* Shop */
.shop-balance { color: var(--m-sub); font-size: 13px; margin-bottom: 12px; text-align: right; flex-shrink: 0; }
.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-content: start; }
.shop-item { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: rgba(128,128,128,0.05); border: 1px solid var(--m-line); border-radius: 7px; text-align: center; align-items: center; justify-content: space-between; min-height: 130px; }
.shop-item.equipped { border-color: var(--m-ac); background: rgba(128,128,128,0.1); }
.shop-item.owned { border-color: var(--m-line); }
.shop-item.locked { border-color: var(--m-line); opacity: 0.85; }
.shop-item-name { font-weight: 600; color: var(--m-fg); font-size: 14px; line-height: 1.2; }
.shop-item-status { color: var(--m-sub); font-size: 12px; }
.shop-item.equipped .shop-item-status { color: var(--m-ac); font-weight: 600; }
.shop-item .ui-btn { min-width: 100px; font-size: 13px; height: 32px; padding: 4px 14px; }

.title-actions-list { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; grid-column: 1 / -1; }
.title-action-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: rgba(128,128,128,0.05); border: 1px solid var(--m-line); border-radius: 7px; padding: 14px 18px; }
.title-action-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.title-action-heading { font-size: 15px; font-weight: 600; color: var(--m-fg); }
.title-action-sub { font-size: 13px; color: var(--m-sub); }
.title-action-btn { height: 34px; padding: 0 18px; font-size: 13px; font-weight: 600; border-radius: 6px; border: none; cursor: pointer; min-width: 100px; flex-shrink: 0; }
.title-action-btn:hover { filter: brightness(1.1); }

/* Card backs */
.card-back { position: relative; overflow: hidden; box-shadow: -2px 0 4px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.15); }
.card-back::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(135deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.05) 30%, transparent 55%, transparent 100%); z-index: 2; }
.card-back.revealed::before { display: none; }
.shop-cb-preview { width: 60px; height: 90px; border-radius: 6px; margin: 0 auto; background: var(--card-back-bg) !important; border: 2px solid white; box-shadow: -2px 0 4px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.15); }
.shop-cb-equipped { width: 160px; height: 240px; border-radius: 8px; background: var(--card-back-bg) !important; border: 2px solid white; box-shadow: 0 6px 18px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.15); }
.shop-cb-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

/* Settings */
.settings-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.settings-row label { width: 110px; text-align: left; font-size: 15px; color: var(--m-fg); }
.settings-row input[type="range"] { flex: 1; height: 22px; accent-color: var(--m-ac); cursor: pointer; }
.settings-row .settings-value { width: 50px; text-align: right; font-size: 14px; color: var(--m-sub); font-variant-numeric: tabular-nums; }

/* Chat */
.chat-box { position: absolute; right: 0; bottom: 0; background: var(--panel-bg); border: 2px solid rgba(255,255,255,0.2); border-radius: 10px 0 0 0; width: 350px; display: flex; flex-direction: column; height: 380px; z-index: 500; }
.chat-tabs { display: flex; border-bottom: 1px solid rgba(255,255,255,0.2); background: rgba(0,0,0,0.3); }
.chat-tab { flex: 1; padding: 10px; font-size: 14px; font-weight: bold; background: transparent; color: #aaa; border: none; cursor: pointer; border-radius: 0; }
.chat-tab.active { color: var(--border-color); border-bottom: 2px solid var(--border-color); background: rgba(255,255,255,0.05); }
.chat-messages { flex: 1; padding: 15px; overflow-y: auto; font-size: 14px; text-align: left; }
.chat-msg { margin-bottom: 10px; word-break: break-word; }
.chat-msg strong { color: var(--text-dim); cursor: pointer; }
.chat-input-area { display: flex; border-top: 1px solid rgba(255,255,255,0.2); padding: 10px; }
.chat-input-area input { flex: 1; min-width: 0; padding: 10px; font-size: 14px; margin: 0; border-radius: 5px; border: none; }
.chat-input-area button { flex-shrink: 0; padding: 10px 20px; font-size: 14px; margin-left: 10px; }

/* Bottom UI */
.bottom-ui { position: absolute; bottom: 0; left: 0; width: 100%; height: 350px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 20px; pointer-events: none; }
.bottom-ui > * { pointer-events: auto; }
.turn-area { position: relative; width: 100%; display: flex; justify-content: center; margin-bottom: 40px; }
.turn-indicator { height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--border-color); font-weight: bold; font-size: 24px; }
.turn-indicator.error { color: #ff4444; font-size: 18px; white-space: nowrap; text-shadow: 0 0 10px rgba(255, 68, 68, 0.7), 0 0 25px rgba(255, 68, 68, 0.4); }
.controls-row { position: relative; display: flex; justify-content: center; align-items: center; width: 1100px; margin-bottom: 10px; }
.controls-center { position: relative; display: flex; justify-content: center; width: 100%; }
#playBtn { z-index: 2; }
#throwTypeBtn { position: absolute; right: 50%; margin-right: 120px; z-index: 1; }
#passBtn { position: absolute; left: 50%; margin-left: 120px; z-index: 1; }
#name-bottom { position: absolute; right: 50%; margin-right: 300px; top: calc(50% - 20px); transform: translateY(-50%); z-index: 3; }
.hand-wrapper { position: relative; display: block; height: 190px; width: 1100px; margin: 0 auto; }
.hand { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 2px dashed rgba(255,255,255,0.15); border-radius: 10px; z-index: 1; }
.hand-btns { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 10; }
button.ui-btn.small-btn { padding: 4px 8px; font-size: 14px; height: 32px; margin: 0; }
button.ui-btn.small-btn:hover { background: #2b6cb0; }

/* Angry + shake */
.angry-toast { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); z-index: 10000; pointer-events: none; text-align: center; }
.angry-text { font-size: 50px; font-weight: 900; color: #ff3333; text-transform: uppercase; text-shadow: 0 0 20px #000, 0 0 40px #ff0000; animation: angryPulse 0.3s infinite alternate; }
@keyframes angryPulse { from { transform: scale(1); } to { transform: scale(1.05); } }
.shake { animation: screenShake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes screenShake { 10%, 90% { transform: translate3d(-2px, 0, 0); } 20%, 80% { transform: translate3d(4px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-8px, 0, 0); } 40%, 60% { transform: translate3d(8px, 0, 0); } }

/* Winner modal */
#profileModal { z-index: 2600; }
#winnerModal { position: absolute; top: 90px; right: 20px; width: 300px; background: var(--table-bg); border: 3px solid var(--border-color); border-radius: 10px; padding: 15px 20px; z-index: 1000; box-shadow: 0 6px 20px rgba(0,0,0,0.55); text-align: center; }
#winnerModal #winnerText { font-size: 20px; margin-bottom: 10px; }
#winnerModal #payoutBreakdown { font-size: 14px; line-height: 1.5; }
#winnerModal #readyStatusText { font-size: 13px; margin-top: 8px; margin-bottom: 0; }
#winnerModal #readyNextBtn { margin-top: 10px; }
#resumeGameBtn { border: 3px solid var(--border-color) !important; box-shadow: 0 0 15px rgba(255, 206, 0, 0.6); animation: resumePulse 1.5s infinite alternate; }
@keyframes resumePulse { from { box-shadow: 0 0 10px rgba(255, 206, 0, 0.4); } to { box-shadow: 0 0 25px rgba(255, 206, 0, 0.9), 0 0 35px rgba(255, 206, 0, 0.5); } }

