@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Noto+Serif+SC:wght@700&family=DM+Mono:wght@500&family=Manrope:wght@600;700&display=swap');

:root { --ink: #161817; --paper: #f3ecd8; --red: #a72e2b; --jade: #174c3a; --jade-dark: #0b2d24; --gold: #d0ad61; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--paper); background: #071711; font-family: Manrope, sans-serif; }
button, input { font: inherit; }
.shell { min-height: 100vh; background: radial-gradient(ellipse at 50% 42%, #1d6048 0, #123e2f 38%, #091d17 78%, #06130f 100%); }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid rgba(208,173,97,.32); background: linear-gradient(90deg, #091711, #10291f 50%, #091711); box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.brand { display: flex; align-items: center; gap: 12px; font-family: Cinzel, serif; font-size: 17px; letter-spacing: 1px; }
.seal, .lobby-mark { display: grid; place-items: center; color: #f7dfb2; background: var(--red); font-family: "Noto Serif SC", serif; }
.seal { width: 38px; height: 38px; border: 2px solid #d9b86d; border-radius: 50%; box-shadow: 0 0 0 3px rgba(167,46,43,.25); }
.room-badge { color: #dbe3d8; font: 500 12px "DM Mono", monospace; border: 1px solid rgba(208,173,97,.38); background: rgba(4,20,15,.42); padding: 8px 10px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.help-button { display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border: 1px solid rgba(208,173,97,.42); border-radius: 2px; color: #e6c985; background: rgba(208,173,97,.06); cursor: pointer; font: 700 11px "DM Mono", monospace; }
.help-button span { display: grid; width: 18px; height: 18px; place-items: center; border: 1px solid currentColor; border-radius: 50%; font: 700 12px Manrope, sans-serif; }
.hidden { display: none !important; }
.lobby { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 170px minmax(260px, 420px) minmax(280px, 380px); align-items: center; justify-content: center; gap: 38px; padding: 40px; }
.lobby-mark { width: 170px; height: 210px; border: 1px solid #d5b36e; outline: 7px solid rgba(167,46,43,.65); outline-offset: -16px; font-size: 92px; box-shadow: 14px 18px 35px rgba(0,0,0,.38); }
.eyebrow { margin: 0 0 8px; color: #c6d1c8; font: 700 11px "DM Mono", monospace; }
h1 { margin: 0; color: #f6efdc; font: 700 58px Cinzel, serif; }
.join-form { display: grid; gap: 14px; }
.join-form label { display: grid; gap: 7px; font: 700 11px "DM Mono", monospace; }
.join-form input { height: 48px; border: 1px solid rgba(208,173,97,.45); border-radius: 2px; background: rgba(7,25,19,.82); padding: 0 12px; color: #fff8e7; text-transform: uppercase; }
.join-error { margin: -4px 0 0; color: #f1a29d; font: 700 11px "DM Mono", monospace; }
.primary, .ghost, .start-button { height: 44px; border-radius: 3px; cursor: pointer; }
.primary { border: 1px solid #d9b86d; background: linear-gradient(#ba3a34, #8f2422); color: #fff8e7; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.24); }
.game { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 190px minmax(0, 1fr) 270px; grid-template-rows: minmax(320px, 1fr) 250px; }
.players-panel { grid-column: 1; grid-row: 1 / 3; border-right: 1px solid rgba(208,173,97,.22); padding: 24px 18px; background: linear-gradient(180deg, rgba(7,25,19,.92), rgba(9,35,27,.82)); }
#players { display: grid; gap: 8px; }
.player { height: 54px; display: grid; grid-template-columns: 34px minmax(0, 1fr) 28px; column-gap: 8px; align-items: center; border-bottom: 1px solid rgba(208,173,97,.12); color: #dfe8df; }
.player.active { border-left: 3px solid #d8b65f; padding-left: 8px; background: rgba(208,173,97,.07); }
.player-dot { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid rgba(208,173,97,.55); border-radius: 50%; background: #0c3125; color: #e9d6a5; font: 700 11px "DM Mono", monospace; }
.player-name { min-width: 0; display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; }
.player-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dealer-star { flex: 0 0 auto; display: inline-block; margin-left: 4px; color: #e5bf61; font-size: 15px; line-height: 1; }
.player strong { font: 700 13px "DM Mono", monospace; }
.start-button { width: 100%; margin-top: 16px; border: 1px solid rgba(208,173,97,.55); background: rgba(208,173,97,.06); color: #e6c985; }
.table { grid-column: 2; grid-row: 1; position: relative; display: grid; place-items: center; background: radial-gradient(circle at 50% 50%, rgba(56,126,94,.22), transparent 58%); }
.table::before { content: ""; position: absolute; width: min(760px, 76%); height: 60%; border: 2px solid rgba(208,173,97,.28); border-radius: 50%; box-shadow: inset 0 0 70px rgba(5,31,23,.9), 0 18px 45px rgba(0,0,0,.28); }
.table::after { content: "勝"; position: absolute; color: rgba(208,173,97,.10); font: 700 132px "Noto Serif SC", serif; }
.table-center { position: relative; z-index: 1; display: grid; justify-items: center; gap: 14px; }
.turn-status { margin: 0; color: #edf3ea; font: 700 12px "DM Mono", monospace; text-transform: uppercase; }
.game-message { max-width: min(440px, calc(100vw - 32px)); margin: 0; padding: 9px 13px; border: 1px solid rgba(226,112,96,.72); border-radius: 2px; color: #ffe4dc; background: rgba(91,25,22,.92); box-shadow: 0 5px 20px rgba(0,0,0,.24); font: 700 12px "DM Mono", monospace; line-height: 1.45; text-align: center; }
.table-cards { min-height: 160px; display: grid; place-items: center; align-content: center; gap: 10px; }
.played-cards { display: flex; justify-content: center; align-items: center; min-height: 132px; }
.played-cards .card { flex-basis: clamp(42px, 5vw, 72px); width: clamp(42px, 5vw, 72px); height: clamp(64px, 7.5vw, 108px); margin: 0 -3px; border-width: 3px; pointer-events: none; }
.play-label, .empty-table { border: 1px solid rgba(208,173,97,.42); background: rgba(7,25,19,.88); color: #f5ebcf; padding: 12px 16px; font: 700 12px "DM Mono", monospace; }
.empty-table { color: #9faf9f; }
.actions { display: flex; gap: 8px; }
.actions button { min-width: 88px; }
.ghost { border: 1px solid rgba(208,173,97,.38); background: rgba(7,25,19,.72); color: #e6dec8; }
.hand-section { grid-column: 2; grid-row: 2; min-width: 0; border-top: 1px solid rgba(208,173,97,.22); background: linear-gradient(180deg, rgba(7,26,20,.96), rgba(5,19,15,.98)); padding: 14px 28px 24px; overflow-x: auto; }
 .hand-heading { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--paper); font: 700 11px "DM Mono", monospace; }
.hand-heading b { color: #f1cf86; font-weight: 700; }
.hand { min-width: max-content; display: flex; align-items: end; height: 180px; padding: 0 8px; }
.hand .card { z-index: 1; flex: 0 0 88px; width: 88px; height: 132px; margin-right: -6px; }
.played-cards .card { --card-color: #27282b; position: relative; border: 3px solid #f8f1dc; border-radius: 4px; outline: 1px solid #b6a985; background: linear-gradient(145deg, #fffaf0 0%, #ece2c5 100%); box-shadow: 0 8px 16px rgba(0,0,0,.38); color: var(--card-color); }
.card { --card-color: #27282b; position: relative; border: 5px solid #f8f1dc; border-radius: 4px; outline: 1px solid #b6a985; background: linear-gradient(145deg, #fffaf0 0%, #ece2c5 100%); box-shadow: 0 8px 16px rgba(0,0,0,.38); cursor: pointer; color: var(--card-color); transition: transform 160ms ease, box-shadow 160ms ease; }
.card::before { content: ""; position: absolute; inset: 3px; border: 1px solid currentColor; border-radius: 1px; opacity: .55; pointer-events: none; }
.card::after { content: ""; position: absolute; top: 5px; right: 5px; bottom: 5px; width: 5px; background: repeating-linear-gradient(180deg, currentColor 0 3px, #f8f1dc 3px 6px); opacity: .78; }
.card:hover { transform: translateY(-8px); }
.card.selected { transform: translateY(-22px); box-shadow: 0 10px 18px rgba(32,32,30,.18); }
.corner-mark { position: absolute; z-index: 2; left: 9px; top: 8px; display: grid; justify-items: center; line-height: .82; font-family: "DM Mono", monospace; }
.corner-mark b { font-size: 15px; }
\.corner-mark em { display: none; }
.corner-mark.bottom { left: auto; top: auto; right: 9px; bottom: 8px; transform: rotate(180deg); }
.pip-rail { position: absolute; z-index: 1; top: 26px; bottom: 24px; display: flex; flex-direction: column; justify-content: space-evenly; }
.pip-rail.left { left: 17px; }
.pip-rail.right { right: 17px; }
.pip-rail i { width: 5px; height: 5px; border: 1px solid currentColor; background: currentColor; transform: rotate(45deg); }
.card-art { position: absolute; z-index: 1; left: 29px; right: 29px; top: 28px; bottom: 25px; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; background: radial-gradient(circle, rgba(255,248,221,.95) 0 38%, currentColor 39% 43%, transparent 44%); transform: rotate(-8deg); }
.card-art b { width: 58%; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid #f8f1dc; border-radius: 50%; background: #f8f1dc; color: var(--card-color); font: 700 34px "Noto Serif SC", serif; transform: rotate(8deg); box-shadow: 0 0 0 3px currentColor; }
.card-art b { width: 58%; min-width: 0; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid #f8f1dc; border-radius: 50%; background: #f8f1dc; color: var(--card-color); font: 700 34px "Noto Serif SC", serif; transform: rotate(8deg); box-shadow: 0 0 0 3px currentColor; }
.card.special-vp .card-art, .card.special-chancellor .card-art, .card.special-rainbow .card-art { left: 18px; right: 18px; transform: none; }
.card.special-vp .card-art b, .card.special-chancellor .card-art b, .card.special-rainbow .card-art b { width: calc(100% - 6px); height: 24px; aspect-ratio: auto; border-radius: 12px; font: 700 12px "DM Mono", monospace; transform: none; box-shadow: 0 0 0 2px currentColor; }
.suit-red { --card-color: #c93630; }
.suit-green { --card-color: #176a52; }
.suit-yellow { --card-color: #d0a52f; }
.suit-rainbow { --card-color: #c93630; background: linear-gradient(135deg, #fffaf0 0 62%, #d0a52f 62% 71%, #176a52 71% 79%, #c93630 79%); }
.suit-rainbow .card-art { background: radial-gradient(circle, #fffaf0 0 38%, #d0a52f 39% 43%, #176a52 44% 48%, #c93630 49% 53%, transparent 54%); }
.chat-panel { grid-column: 3; grid-row: 1 / 3; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid rgba(208,173,97,.22); background: linear-gradient(180deg, rgba(7,25,19,.88), rgba(5,19,15,.96)); }
.chat-heading { display: flex; justify-content: space-between; padding: 18px 16px 12px; color: #e6c985; font: 700 11px "DM Mono", monospace; border-bottom: 1px solid rgba(208,173,97,.18); }
.chat-heading span:last-child { color: #9faf9f; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-message { max-width: 100%; padding: 8px 9px; border-left: 2px solid rgba(208,173,97,.45); background: rgba(255,255,255,.035); overflow-wrap: anywhere; }
.chat-message.own { border-left-color: #c64b42; }
.chat-message b { color: #e5bf61; font: 700 11px "DM Mono", monospace; }
.chat-message p { margin: 4px 0 0; color: #e3e7dd; font-size: 13px; line-height: 1.4; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(208,173,97,.18); }
.chat-form input { width: 0; min-width: 0; flex: 1; height: 38px; border: 1px solid rgba(208,173,97,.3); border-radius: 2px; padding: 0 8px; color: #f3ecd8; background: rgba(5,19,15,.8); }
.chat-send { min-width: 54px; border: 1px solid rgba(208,173,97,.5); border-radius: 2px; color: #e6c985; background: rgba(208,173,97,.08); cursor: pointer; }
.win-overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-content: center; justify-items: center; background: radial-gradient(circle, rgba(208,173,97,.24), rgba(5,16,12,.86) 58%, rgba(4,12,9,.96)); text-align: center; }
.win-overlay.hidden { display: none; }
.win-seal { width: 148px; height: 148px; display: grid; place-items: center; border: 5px solid #e0bd70; border-radius: 50%; background: radial-gradient(circle, #bb3a35 0 60%, #8e2523 61%); color: #fff1c7; font: 700 82px "Noto Serif SC", serif; box-shadow: 0 0 0 12px rgba(167,46,43,.2), 0 28px 60px rgba(0,0,0,.45); }
.win-kicker { margin: 22px 0 4px; color: #d5bb78; font: 700 12px "DM Mono", monospace; letter-spacing: 3px; }
.win-overlay h2 { margin: 0; color: #fff8e3; font: 700 52px Cinzel, serif; text-shadow: 0 4px 18px rgba(0,0,0,.5); }
.win-card-line { display: grid; grid-template-columns: 70px auto 70px; align-items: center; gap: 12px; margin-top: 14px; color: #d5bb78; font: 700 11px "DM Mono", monospace; }
.win-card-line span { height: 1px; background: #d5bb78; }
.win-rays { position: absolute; width: 520px; height: 520px; opacity: .16; background: repeating-conic-gradient(from 0deg, #d5bb78 0 3deg, transparent 3deg 12deg); animation: rotateRay 18s linear infinite; }
.help-dialog { width: min(680px, calc(100vw - 28px)); max-width: none; max-height: min(86vh, 780px); padding: 0; border: 1px solid rgba(208,173,97,.55); border-radius: 3px; color: var(--paper); background: linear-gradient(145deg, #113629, #071b14 72%); box-shadow: 0 24px 80px rgba(0,0,0,.62); }
.help-dialog::backdrop { background: rgba(2,10,7,.78); backdrop-filter: blur(4px); }
.help-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 14px; border-bottom: 1px solid rgba(208,173,97,.25); background: #102b21; }
.help-header .eyebrow { margin-bottom: 4px; color: #d0ad61; }
.help-header h2 { margin: 0; color: #fff4d8; font: 700 25px Cinzel, serif; }
.help-close { width: 36px; height: 36px; border: 1px solid rgba(208,173,97,.42); border-radius: 2px; color: #f3ecd8; background: transparent; cursor: pointer; font-size: 24px; line-height: 1; }
.help-content { padding: 4px 22px 22px; overflow-y: auto; }
.help-content section { padding: 13px 0; border-bottom: 1px solid rgba(208,173,97,.16); }
.help-content h3 { margin: 0 0 7px; color: #e5bf61; font: 700 12px "DM Mono", monospace; text-transform: uppercase; }
.help-content p, .help-content li { color: #e0e6dc; font-size: 13px; line-height: 1.55; }
.help-content p { margin: 6px 0; }
.help-content ul { margin: 6px 0 8px; padding-left: 19px; }
.help-content li + li { margin-top: 4px; }
.help-content b { color: #fff1cb; }
.score-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 20px; }
.help-note { padding-top: 10px; color: #aebdae !important; font-size: 11px !important; }
.play-win .win-seal { animation: sealRise 700ms cubic-bezier(.2,.85,.25,1.25) both, sealPulse 900ms 800ms ease-in-out; }
.play-win h2 { animation: titleIn 600ms 220ms both; }
.fade-away { animation: fadeAway 600ms both; }
@keyframes sealRise { from { opacity: 0; transform: scale(.2) rotate(-20deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes sealPulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 22px rgba(208,173,97,.12), 0 28px 60px rgba(0,0,0,.45); } }
@keyframes titleIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeAway { to { opacity: 0; } }
@keyframes rotateRay { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .topbar { height: 56px; gap: 8px; padding: 0 10px; }
  .brand { gap: 7px; font-size: 13px; }
  .topbar .seal { width: 32px; height: 32px; }
  .topbar-actions { gap: 6px; }
  .help-button { height: 34px; padding: 0 8px; }
  .room-badge { padding: 7px 6px; font-size: 10px; }
  .lobby { grid-template-columns: 1fr; align-content: center; gap: 18px; padding: 24px; }
  .lobby-mark { width: 96px; height: 118px; font-size: 54px; }
  h1 { font-size: 42px; }
  .game { min-height: calc(100vh - 56px); grid-template-columns: minmax(0, 1fr); grid-template-rows: 72px minmax(280px, 1fr) 190px 220px; }
  .players-panel { grid-column: 1; grid-row: 1; border-right: 0; border-bottom: 1px solid rgba(32,32,30,.16); padding: 8px 12px; display: flex; gap: 8px; overflow-x: auto; }
  .players-panel .eyebrow { display: none; }
  #players { display: flex; }
  .player { min-width: 170px; height: 54px; border-bottom: 0; }
  .start-button { position: absolute; right: 12px; top: 64px; z-index: 3; width: 110px; }
  .table { grid-column: 1; grid-row: 2; min-width: 0; }
  .chat-panel { grid-column: 1; grid-row: 3; border-left: 0; border-top: 1px solid rgba(208,173,97,.22); }
  .chat-heading { padding: 9px 12px 7px; }
  .chat-messages { padding: 7px 10px; }
  .chat-form { padding: 6px 10px; }
  .hand-section { grid-column: 1; grid-row: 4; padding: 10px 12px 18px; }
  .hand { height: 160px; }
  .hand .card { flex-basis: 76px; width: 76px; height: 116px; margin-right: -5px; }
  .hand { height: 160px; }
  .hand .card-art { left: 24px; right: 24px; }
  .hand .pip-rail.left { left: 14px; }
  .hand .pip-rail.right { right: 14px; }
  .help-header { padding: 14px 16px 12px; }
  .help-content { padding: 2px 16px 16px; }
  .score-list { grid-template-columns: 1fr; }
}
