/* NEXUS CARDS — dark pirate UI over the Three.js sea */
:root {
  --gold: #c9a14f;
  --gold-dim: #8a6d34;
  --parch: #efe2c0;
  --ink: #0c0a07;
  --panel: rgba(16, 12, 8, .88);
  --panel-edge: rgba(201, 161, 79, .55);
  --ocean: #2e6fb2; --jungle: #5a9c33; --crimson: #b03326; --storm: #c9a227;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Georgia, 'Palatino Linotype', 'Times New Roman', serif;
  color: var(--parch);
  background:
    radial-gradient(ellipse at 50% -10%, #11203a 0%, transparent 55%),
    linear-gradient(#05070d, #03040a 60%, #020308);
  overflow: hidden;
  user-select: none;
}
#sea { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; }
#deckglow {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 115%, rgba(255, 179, 71, .14) 0%, transparent 45%),
              radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0,0,0,.55) 100%);
}
#app { position: relative; z-index: 2; height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
.muted { color: rgba(239,226,192,.55); }
.small { font-size: .8rem; }
.err { color: #ff8a5e; min-height: 1.2em; margin-top: .5rem; font-size: .9rem; }
.gold-t { color: var(--gold); }

/* ---------- chrome ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .9rem; gap: .8rem;
}
.brand-mini { font-weight: bold; letter-spacing: .18em; color: var(--gold); font-size: 1rem; }
.brand-mini span { color: var(--parch); opacity: .7; margin-left: .35em; font-size: .8em; letter-spacing: .3em; }
#roomtag { display: flex; align-items: center; gap: .6rem; }
#roomcode { font-weight: bold; letter-spacing: .25em; color: var(--gold); }
.top-actions { display: flex; gap: .4rem; }

button {
  font-family: inherit; cursor: pointer; color: var(--parch);
  border-radius: 8px; border: 1px solid var(--panel-edge);
  background: linear-gradient(#241a0e, #160f08);
  padding: .5rem .9rem; font-size: .95rem;
  transition: transform .08s, box-shadow .15s, filter .15s;
}
button:hover { filter: brightness(1.25); }
button:active { transform: translateY(1px); }
button.gold {
  background: linear-gradient(#e3bd6b, #a87f33 55%, #7c5b22);
  color: #1d1305; font-weight: bold; border-color: #5c431a;
  text-shadow: 0 1px 0 rgba(255,255,255,.25);
  box-shadow: 0 2px 10px rgba(201,161,79,.25), inset 0 1px 0 rgba(255,255,255,.35);
}
button.big { font-size: 1.15rem; padding: .8rem 1.2rem; width: 100%; }
button.ghost { background: rgba(20,14,8,.6); font-size: .85rem; }
button:disabled { opacity: .45; cursor: default; filter: none; }

input, select {
  font-family: inherit; font-size: 1rem; color: var(--parch);
  background: rgba(8,6,3,.8); border: 1px solid var(--panel-edge);
  border-radius: 8px; padding: .6rem .8rem; outline: none; width: 100%;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,161,79,.2); }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow: 0 14px 50px rgba(0,0,0,.6), inset 0 0 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.06);
  padding: 1.4rem;
  backdrop-filter: blur(3px);
}

/* ---------- home ---------- */
.view { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem; padding: 1rem; overflow: hidden; }
.logo { text-align: center; line-height: 1; }
.logo-nexus {
  font-size: clamp(3.2rem, 9vw, 6rem); font-weight: bold; letter-spacing: .12em;
  background: linear-gradient(#fdf3d0 15%, #e8c97e 40%, #97742f 75%, #caa452);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.85)) drop-shadow(0 0 22px rgba(201,161,79,.3));
}
.logo-cards { letter-spacing: .65em; color: var(--gold); margin-top: .5rem; font-size: clamp(1rem, 2.6vw, 1.5rem); text-indent: .65em; }
.logo-tag { margin-top: .7rem; color: rgba(239,226,192,.7); font-style: italic; font-size: clamp(.85rem, 2vw, 1.05rem); }
#home-medallions { display: flex; gap: 1.1rem; }
#home-medallions canvas { width: 58px; height: 58px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.7)); }
.home-panel { width: min(380px, 92vw); display: flex; flex-direction: column; gap: .65rem; }
.home-panel label { font-size: .85rem; color: rgba(239,226,192,.7); }
.divider { display: flex; align-items: center; gap: .8rem; color: rgba(239,226,192,.45); font-size: .8rem; margin: .3rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(201,161,79,.3); }
.joinrow { display: flex; gap: .6rem; }
.joinrow input { text-transform: uppercase; letter-spacing: .35em; width: 0; flex: 1; text-align: center; }
.home-foot { color: rgba(239,226,192,.45); font-size: .85rem; }
.home-foot a { color: var(--gold); }

/* ---------- lobby ---------- */
.lobby-panel { width: min(430px, 94vw); display: flex; flex-direction: column; gap: .8rem; text-align: center; }
.lobby-panel h2 { color: var(--gold); letter-spacing: .05em; }
.code-display b { letter-spacing: .4em; color: var(--gold); font-size: 1.5rem; margin-left: .4rem; }
#lobby-players { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
#lobby-players li {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .8rem;
  background: rgba(8,6,3,.6); border: 1px solid rgba(201,161,79,.25); border-radius: 8px;
}
#lobby-players .who { flex: 1; text-align: left; }
#lobby-players .tag { font-size: .75rem; color: var(--gold); }
#lobby-players .kick { font-size: .7rem; padding: .15rem .5rem; }
.lobby-opts { display: flex; align-items: center; gap: .8rem; justify-content: center; }
.lobby-opts select { width: auto; }

/* ---------- game ---------- */
#view-game { justify-content: flex-start; gap: 0; padding: 0; }
#opponents {
  display: flex; justify-content: center; align-items: flex-start; gap: clamp(.4rem, 1.6vw, 1.4rem);
  padding: .4rem .5rem 0; width: 100%; flex-wrap: wrap;
}
.opp {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .45rem .7rem .4rem; min-width: 92px;
  background: var(--panel); border: 1px solid rgba(201,161,79,.3); border-radius: 12px;
  transition: box-shadow .25s, border-color .25s;
}
.opp.turn { border-color: var(--gold); box-shadow: 0 0 18px rgba(201,161,79,.45); }
.opp.gone { opacity: .45; }
.opp .nm { font-size: .85rem; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .cards { display: flex; height: 30px; margin-top: .15rem; }
.opp .cards i {
  width: 20px; height: 29px; margin-right: -12px; border-radius: 3px;
  background: linear-gradient(135deg, #15233a, #0a1018 70%);
  border: 1px solid rgba(201,161,79,.5);
}
.opp .cnt { font-size: .78rem; color: var(--gold); }
.opp .score { font-size: .7rem; color: rgba(239,226,192,.55); }
.opp .called {
  position: absolute; top: -10px; right: -8px; background: var(--gold); color: #1d1305;
  border-radius: 8px; padding: 0 .45rem; font-size: .72rem; font-weight: bold;
}
.opp .catchbtn {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(#d4502f, #8a2417); color: #fff; border-color: #5c1208;
  font-size: .72rem; padding: .12rem .5rem; border-radius: 9px; white-space: nowrap;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 14px rgba(212,80,47,.8); } }

#table { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; width: 100%; position: relative; }
#turnbanner { font-size: clamp(1rem, 2.6vw, 1.4rem); color: var(--gold); text-shadow: 0 2px 6px #000; letter-spacing: .04em; min-height: 1.5em; }
.piles { display: flex; align-items: center; gap: clamp(1rem, 4vw, 3rem); }
#drawpile { position: relative; cursor: pointer; transition: transform .12s; }
#drawpile:hover { transform: translateY(-4px); }
#drawpile.pulse { animation: drawPulse 1.4s infinite; border-radius: 12px; }
@keyframes drawPulse { 50% { box-shadow: 0 0 26px rgba(201,161,79,.55); } }
#drawpile canvas, #discard canvas { display: block; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.7); }
#deckcount {
  position: absolute; bottom: -8px; right: -8px; background: var(--panel);
  border: 1px solid var(--panel-edge); border-radius: 10px; padding: .1rem .5rem; font-size: .8rem; color: var(--gold);
}
#discard { position: relative; }
#discard canvas { transition: transform .15s; }
#discard.flip canvas { animation: flipIn .3s ease-out; }
@keyframes flipIn { from { transform: rotateY(70deg) scale(1.1); } to { transform: none; } }
#tableinfo { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
#colorMedallion { filter: drop-shadow(0 4px 10px rgba(0,0,0,.8)); }
#dirArrow { font-size: 1.8rem; color: var(--gold); transition: transform .4s; text-shadow: 0 0 12px rgba(201,161,79,.5); }
#dirArrow.rev { transform: scaleX(-1); }
#timerbar { width: min(300px, 60vw); height: 5px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
#timerfill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), #e3bd6b); border-radius: 3px; transition: width 1s linear; }

#actionbar { display: flex; gap: .8rem; padding: .2rem; min-height: 52px; align-items: center; }
#btn-nexus {
  font-size: 1.25rem; font-weight: bold; letter-spacing: .08em; padding: .55rem 1.6rem; border-radius: 999px;
  background: radial-gradient(circle at 50% 30%, #ffd984, #c9892a 60%, #8a5b16);
  color: #221302; border: 2px solid #f1d9a0; text-shadow: 0 1px 0 rgba(255,255,255,.4);
  animation: pulse 1s infinite;
}

#hand {
  display: flex; justify-content: center; align-items: flex-end;
  padding: 0 1rem .9rem; width: 100%; min-height: 150px;
}
.handcard {
  position: relative; margin: 0 max(-26px, calc(-1 * min(26px, 2.4vw)));
  transition: transform .14s ease, filter .14s;
  cursor: pointer;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.65));
}
.handcard canvas { display: block; border-radius: 10px; }
.handcard:hover { transform: translateY(-26px) scale(1.07); z-index: 50 !important; }
.handcard.dead { cursor: default; filter: drop-shadow(0 8px 14px rgba(0,0,0,.65)) brightness(.45) saturate(.6); }
.handcard.dead:hover { transform: translateY(-8px); }
.handcard.fresh::after {
  content: 'NEW'; position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #1d1305; font-size: .62rem; font-weight: bold; border-radius: 6px; padding: 0 .35rem;
}
#me-info { text-align: center; padding-bottom: .4rem; font-size: .85rem; color: rgba(239,226,192,.6); }
#me-info b { color: var(--gold); }

/* event log + chat */
#log {
  position: fixed; left: .8rem; top: 3.4rem; z-index: 5; width: min(250px, 42vw);
  display: flex; flex-direction: column; gap: .3rem; pointer-events: none;
}
.logline {
  background: rgba(10,7,4,.82); border-left: 3px solid var(--gold-dim);
  padding: .3rem .55rem; border-radius: 0 8px 8px 0; font-size: .8rem;
  animation: slideIn .25s ease-out; max-width: 100%;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } }
#chatbox {
  position: fixed; right: .8rem; bottom: .8rem; z-index: 6; width: min(240px, 50vw);
  display: flex; flex-direction: column; gap: .3rem;
}
#chatlog { display: flex; flex-direction: column; gap: .2rem; max-height: 30vh; overflow-y: auto; }
.chatline { background: rgba(10,7,4,.8); border-radius: 8px; padding: .25rem .5rem; font-size: .8rem; }
.chatline b { color: var(--gold); }
#chatform { display: flex; gap: .3rem; }
#chatform input { padding: .35rem .6rem; font-size: .85rem; background: rgba(10,7,4,.85); }
#chatform button { padding: .3rem .6rem; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(2,3,6,.7); backdrop-filter: blur(2px);
}
.modal-card {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 16px;
  padding: 1.6rem; width: min(440px, 92vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 20px 80px rgba(0,0,0,.8); text-align: center;
  display: flex; flex-direction: column; gap: .9rem;
}
.modal-card h3 { color: var(--gold); letter-spacing: .05em; }
#color-options { display: flex; justify-content: center; gap: 1rem; }
#color-options .copt { background: none; border: none; padding: .2rem; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
#color-options canvas { width: 76px; height: 76px; transition: transform .12s; }
#color-options .copt:hover canvas { transform: scale(1.12); }
#color-options .copt span { font-size: .8rem; letter-spacing: .1em; }
.help-card { text-align: left; }
.help-card h3 { text-align: center; }
.rules { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.guide { width: 100%; border-collapse: collapse; font-size: .9rem; }
.guide td { padding: .35rem .5rem; border-bottom: 1px solid rgba(201,161,79,.18); }
.guide td:first-child { color: var(--gold); white-space: nowrap; font-weight: bold; }
.score-table { width: 100%; border-collapse: collapse; }
.score-table td, .score-table th { padding: .35rem .6rem; border-bottom: 1px solid rgba(201,161,79,.18); text-align: left; }
.score-table .winner td { color: var(--gold); font-weight: bold; }

#toasts { position: fixed; top: 3.2rem; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast {
  background: rgba(14,10,5,.92); border: 1px solid var(--panel-edge); color: var(--parch);
  border-radius: 10px; padding: .5rem 1.1rem; font-size: .95rem; box-shadow: 0 8px 30px rgba(0,0,0,.6);
  animation: toastIn .25s ease-out;
}
.toast.big { font-size: 1.3rem; color: var(--gold); padding: .8rem 1.6rem; letter-spacing: .06em; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.95); } }

@media (max-width: 640px) {
  #log { display: none; }
  .opp { min-width: 74px; padding: .3rem .45rem; }
  #chatbox { width: 46vw; }
  .handcard:hover { transform: translateY(-14px); }
}
