@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@400;500;700&display=swap');

:root {
  --navy: #0a0f1e; --cyan: #00d4ff; --white: #f0f4ff; --silver: #c8d6e8; --muted: #8aa0c4;
  --felt: #0f5a3c; --felt-d: #0a3f2a; --gold: #f4c150; --cw: 56px; --ch: 78px;
  --ink: #111827; --red: #c81e3a;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.tk { background: var(--navy); color: var(--white); font-family: 'DM Sans', system-ui, sans-serif;
  overflow-x: hidden; min-height: 100vh; -webkit-text-size-adjust: 100%; }
.tk button { font-family: inherit; }

.tk-wrap { max-width: 960px; margin: 0 auto; padding: 8px 8px 20px; }
.tk-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tk-back { color: var(--cyan); text-decoration: none; font-size: .86rem; font-weight: 500; white-space: nowrap; }
.tk-back:hover { text-decoration: underline; }
.tk-title { text-align: center; line-height: 1; min-width: 0; }
.tk-title h1 { font-family: 'Bebas Neue', sans-serif; font-weight: 400; font-size: 1.7rem; letter-spacing: 1px; margin: 0; }
.tk-title h1 span { color: var(--gold); }
.tk-title p { margin: 2px 0 0; font-size: .7rem; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.tk-tools { display: flex; gap: 5px; }
.tk-ibtn { background: rgba(255,255,255,.08); color: var(--white); border: 1px solid rgba(255,255,255,.15); border-radius: 9px;
  min-width: 36px; height: 36px; font-size: 1rem; cursor: pointer; padding: 0 8px; }
.tk-ibtn:hover { background: rgba(0,212,255,.18); }

/* score strip */
.tk-score { display: flex; gap: 6px; margin-bottom: 6px; }
.tk-score .sc { flex: 1; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 10px;
  padding: 5px 8px; font-size: .78rem; text-align: center; min-width: 0; }
.tk-score .sc b { display: block; font-size: 1.15rem; font-weight: 700; color: var(--white); }
.tk-score .sc small { color: var(--muted); }
.tk-score .sc.me { border-color: rgba(244,193,80,.6); }

/* felt table */
.tk-table { position: relative; border-radius: 18px; padding: 8px 6px 16px;
  background: radial-gradient(ellipse at 50% 40%, #167a52 0%, var(--felt) 55%, var(--felt-d) 100%);
  border: 3px solid #3b2a14; box-shadow: inset 0 0 40px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.4); }
.tk-grid { display: grid; grid-template-columns: 62px 1fr 62px; grid-template-rows: auto auto; gap: 4px; }
.tk-seat-top { grid-column: 1 / 4; display: flex; justify-content: center; }
.tk-seat-left { grid-column: 1; grid-row: 2; align-self: center; }
.tk-seat-right { grid-column: 3; grid-row: 2; align-self: center; }
.tk-center { grid-column: 2; grid-row: 2; position: relative; height: calc(var(--ch) * 2 + 18px); }

.plate { background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 4px 6px;
  text-align: center; font-size: .72rem; line-height: 1.25; color: var(--white); min-width: 0; transition: box-shadow .2s, border-color .2s; }
.plate .nm { font-weight: 700; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate .st { color: var(--silver); }
.plate.turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(244,193,80,.5), 0 0 14px rgba(244,193,80,.5); }
.plate .cnt { display: inline-block; background: rgba(255,255,255,.14); border-radius: 8px; padding: 0 6px; font-weight: 700; margin-top: 2px; }
.plate.top { min-width: 150px; padding: 4px 14px; }
.plate.side { width: 62px; padding: 4px 3px; }
.plate .tag { display: inline-block; font-size: .64rem; padding: 0 5px; border-radius: 7px; background: var(--gold); color: #3b2a14; font-weight: 700; margin-top: 2px; }

/* trick area */
.slot { position: absolute; transition: transform .25s ease, opacity .25s; }
.slot.s0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.slot.s2 { left: 50%; top: 0; transform: translateX(-50%); }
.slot.s1 { left: 2%; top: 50%; margin-top: calc(var(--ch) / -2 + 4px); }
.slot.s3 { right: 2%; top: 50%; margin-top: calc(var(--ch) / -2 + 4px); }
.slot .tk-card { --cw: 48px; --ch: 67px; cursor: default; position: relative; }
.slot.win .tk-card { box-shadow: 0 0 0 3px var(--gold), 0 0 16px rgba(244,193,80,.8); }
.tk-msg { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; pointer-events: none;
  font-size: .85rem; font-weight: 500; color: var(--silver); text-shadow: 0 1px 2px #000; padding: 0 4px; }

/* cards */
.tk-card { position: relative; width: var(--cw); height: var(--ch); background: linear-gradient(160deg, #fff 0%, #f1f5fb 100%);
  border-radius: 8px; border: 1px solid #aeb8c8; box-shadow: 0 2px 5px rgba(0,0,0,.4); user-select: none; -webkit-user-select: none;
  flex: 0 0 auto; font-family: 'DM Sans', system-ui, sans-serif; overflow: hidden; }
.tk-card.blk { color: var(--ink); } .tk-card.red { color: var(--red); }
.tk-card .ix { position: absolute; left: 4px; top: 2px; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.tk-card .ix b { font-size: calc(var(--cw) * .36); font-weight: 700; }
.tk-card .ix i { font-style: normal; font-size: calc(var(--cw) * .3); margin-top: 1px; }
.tk-card .pip { position: absolute; right: 5px; bottom: 3px; font-size: calc(var(--cw) * .62); line-height: 1; opacity: .92; }
.tk-card.tk-back { background: repeating-linear-gradient(45deg, #1b3f8f 0 5px, #234fb0 5px 10px); border: 2px solid #fff; }

/* hand */
.tk-handbox { position: relative; height: calc(var(--ch) + 22px); margin-top: 6px; }
.tk-handbox .tk-card { position: absolute; bottom: 0; cursor: pointer; transition: transform .15s, box-shadow .15s, filter .15s; }
.tk-handbox .tk-card.legal { transform: translateY(-8px); box-shadow: 0 3px 8px rgba(0,0,0,.5), 0 0 0 2px rgba(0,212,255,.9); }
.tk-handbox .tk-card.sel { transform: translateY(-20px); box-shadow: 0 6px 14px rgba(0,0,0,.55), 0 0 0 3px var(--gold); }
.tk-handbox .tk-card.dim { filter: brightness(.55) saturate(.6); cursor: not-allowed; }
.tk-handbox .tk-card.fresh { animation: fresh 1.6s ease-out 1; }
@keyframes fresh { 0%, 60% { box-shadow: 0 0 0 3px #7CFC9A, 0 0 14px #7CFC9A; } 100% { } }

.tk-status { text-align: center; min-height: 1.5em; margin-top: 6px; font-size: .88rem; color: var(--white); font-weight: 500; }
.tk-actions { display: flex; justify-content: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tk-btn { background: var(--cyan); color: var(--navy); border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 700; font-size: .95rem; cursor: pointer; }
.tk-btn:hover { filter: brightness(1.1); }
.tk-btn:disabled { background: #33415a; color: #7e8aa3; cursor: not-allowed; filter: none; }
.tk-btn.alt { background: rgba(255,255,255,.1); color: var(--white); border: 1px solid rgba(255,255,255,.2); }

/* bid panel */
.tk-bid { background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.16); border-radius: 14px; padding: 10px; margin-top: 8px; text-align: center; }
.tk-bid h3 { margin: 0 0 6px; font-size: .95rem; }
.tk-bid .hint { font-size: .78rem; color: var(--silver); margin-bottom: 8px; }
.bidgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.bidgrid button { background: rgba(255,255,255,.12); color: var(--white); border: 1px solid rgba(255,255,255,.2); border-radius: 9px;
  padding: 10px 0; font-size: 1rem; font-weight: 700; cursor: pointer; }
.bidgrid button:hover { background: var(--cyan); color: var(--navy); }
.bidgrid button.nil { background: rgba(244,193,80,.2); border-color: var(--gold); color: var(--gold); }
.bidgrid button.nil:hover { background: var(--gold); color: #3b2a14; }

/* modals */
.tk-modal { position: fixed; inset: 0; background: rgba(4,8,18,.78); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 10px; }
.tk-modal-card { background: #121b33; border: 1px solid rgba(0,212,255,.25); border-radius: 16px; width: 100%; max-width: 520px; max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.tk-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.tk-modal-head h2 { margin: 0; font-family: 'Bebas Neue', sans-serif; font-weight: 400; letter-spacing: 1px; font-size: 1.5rem; color: var(--gold); }
.tk-x { background: none; border: 0; color: var(--silver); font-size: 1.2rem; cursor: pointer; width: 34px; height: 34px; }
.tk-modal-body { padding: 10px 14px 14px; overflow-y: auto; font-size: .9rem; line-height: 1.5; color: var(--silver); }
.tk-modal-body h4 { color: var(--white); margin: 12px 0 3px; font-size: .95rem; }
.tk-modal-body ul { margin: 4px 0; padding-left: 18px; }
.tk-modal-body p { margin: 4px 0; }
.tk-modal-body .vi { color: var(--muted); font-style: italic; }
.tk-set { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.tk-set label { color: var(--white); font-weight: 500; }
.tk-set select { background: #0a0f1e; color: var(--white); border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 6px 8px; font-size: .9rem; }
.tk-set input[type=checkbox] { width: 22px; height: 22px; }

/* score sheet table */
.sheet { width: 100%; border-collapse: collapse; font-size: .82rem; }
.sheet th, .sheet td { padding: 5px 4px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.08); }
.sheet th { color: var(--gold); font-weight: 700; }
.sheet tr.tot td { font-weight: 700; color: var(--white); border-top: 2px solid rgba(255,255,255,.25); }
.sheet .pos { color: #7CFC9A; } .sheet .neg { color: #ff8a9a; }
.sheet .moon { color: var(--gold); }

.tk-big { text-align: center; padding: 6px 0; }
.tk-big .hd { font-family: 'Bebas Neue', sans-serif; font-size: 2.2rem; letter-spacing: 1px; color: var(--gold); }

@media (min-width: 700px) {
  :root { --cw: 72px; --ch: 100px; }
  .tk-grid { grid-template-columns: 130px 1fr 130px; }
  .plate.side { width: 124px; padding: 8px 6px; } .plate { font-size: .85rem; } .plate .nm { font-size: .95rem; }
  .slot .tk-card { --cw: 62px; --ch: 87px; }
  .tk-center { height: calc(var(--ch) * 2 + 10px); }
  .tk-wrap { padding: 14px; }
  .tk-title h1 { font-size: 2.3rem; }
}
@media (prefers-reduced-motion: reduce) { .slot, .tk-card { transition: none !important; } .tk-handbox .tk-card.fresh { animation: none; } }
.tk-seat-bottom { display: flex; justify-content: center; margin-top: 6px; }
.plate.me { min-width: 150px; padding: 3px 14px; }
@media (max-width: 440px) {
  .tk-top { flex-wrap: wrap; }
  .tk-title { order: 3; flex-basis: 100%; margin-top: 2px; }
}
