/* Euchre — mobile web. Original design; cards drawn in CSS, no image assets. */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --felt: #0a6b3c;
  --felt-dark: #07502c;
  --felt-edge: #053a1f;
  --gold: #f3c14b;
  --us: #4aa8ff;
  --them: #ff7a66;
  --card-w: 58px;
  --card-h: 84px;
  --hand-card-w: 64px;
  --hand-card-h: 92px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #06301b;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.hidden { display: none !important; }
.red { color: #d0302f; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ============ Menu ============ */

#screen-menu {
  background: radial-gradient(120% 90% at 50% 20%, var(--felt) 0%, var(--felt-dark) 55%, #04220f 100%);
  align-items: center;
  justify-content: center;
}

.menu-inner {
  width: min(92vw, 380px);
  display: flex;
  flex-direction: column;
  gap: 26px;
  text-align: center;
}

.menu-logo h1 {
  font-size: 54px;
  letter-spacing: 3px;
  text-shadow: 0 3px 0 rgba(0,0,0,.35);
  color: var(--gold);
}

.tagline { opacity: .8; font-size: 14px; margin-top: 6px; }

.logo-cards {
  display: flex;
  justify-content: center;
  height: 92px;
  margin-bottom: 8px;
}

.logo-card {
  width: 62px; height: 88px;
  background: #fdfdf6;
  color: #111;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,.45);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700;
  margin: 0 -12px;
}
.logo-card span { font-size: 30px; line-height: 1; }
.lc1 { transform: rotate(-14deg) translateY(8px); }
.lc2 { transform: translateY(-2px); z-index: 1; }
.lc3 { transform: rotate(14deg) translateY(8px); }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; }

.menu-footer { font-size: 12px; opacity: .55; }

/* ============ Buttons ============ */

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,.14);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 2px 6px rgba(0,0,0,.25);
  cursor: pointer;
}
.btn:active { transform: translateY(1px); filter: brightness(1.1); }
a.btn { display: block; text-align: center; text-decoration: none; }
.btn-primary { background: linear-gradient(#ffd35e, #e8a825); color: #4a3403; }
.btn-danger { background: linear-gradient(#e26a5a, #c74a3a); }

.hud-btn {
  appearance: none;
  border: none;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(0,0,0,.3);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  flex: none;
}

/* ============ Game screen ============ */

#screen-game { background: var(--felt-edge); }

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,.35);
}

.hud-score { display: flex; gap: 6px; }

.score-box {
  display: flex; flex-direction: column; align-items: center;
  min-width: 46px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(0,0,0,.3);
}
.score-box.us { box-shadow: inset 0 0 0 2px var(--us); }
.score-box.them { box-shadow: inset 0 0 0 2px var(--them); }
.score-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; opacity: .75; }
.score-val { font-size: 18px; font-weight: 700; }

.hud-trump {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #fdfdf6;
  color: #111;
}
.trump-suit { font-size: 22px; line-height: 1; }
.trump-caller { font-size: 11px; color: #444; max-width: 90px; }

.hud-tricks {
  margin-left: auto;
  display: flex; align-items: baseline; gap: 4px;
  font-weight: 700;
}
.tricks-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; opacity: .75; margin-right: 2px; }
.tricks-val { font-size: 18px; }
.tricks-sep { opacity: .5; }
.us-color { color: var(--us); }
.them-color { color: var(--them); }

/* ---- Table ---- */

.table {
  position: relative;
  flex: 1;
  min-height: 0;
}

.table-felt {
  position: absolute;
  inset: 8px;
  border-radius: 26px;
  background:
    radial-gradient(90% 70% at 50% 40%, var(--felt) 0%, var(--felt-dark) 75%, var(--felt-edge) 100%);
  box-shadow:
    inset 0 0 0 6px #3b2a14,
    inset 0 0 0 8px #57401f,
    inset 0 10px 40px rgba(0,0,0,.45);
}

/* ---- Seats ---- */

.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  z-index: 3;
}
.seat-north { top: 16px; left: 50%; transform: translateX(-50%); }
.seat-west  { left: 14px; top: 34%; transform: translateY(-50%); }
.seat-east  { right: 14px; top: 34%; transform: translateY(-50%); }
.seat-south { bottom: 6px; left: 50%; transform: translateX(-50%); }

.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(#7fa8c9, #4a7396);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px;
  box-shadow: 0 2px 6px rgba(0,0,0,.4), inset 0 0 0 2px rgba(255,255,255,.35);
}
#avatar-2 { background: linear-gradient(#8ec98f, #4d8a50); }
#avatar-3 { background: linear-gradient(#c9a97f, #96744a); }

.seat.active .avatar {
  box-shadow: 0 0 0 3px var(--gold), 0 0 14px 3px rgba(243,193,75,.75);
}
.seat.sitting-out { opacity: .38; }

.seat-name { font-size: 12px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

.seat-cards { display: flex; height: 30px; }
.seat-cards .card {
  width: 20px; height: 29px;
  border-radius: 3px;
  margin: 0 -6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}

.dealer-chip {
  position: absolute;
  top: -6px; right: -10px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fdfdf6;
  color: #7a1f1f;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
  z-index: 4;
}
.seat-south .dealer-chip { top: auto; bottom: 0; right: -34px; }

.bubble {
  position: absolute;
  top: 100%;
  margin-top: 4px;
  background: #fdfdf6;
  color: #222;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  z-index: 6;
  animation: pop .18s ease-out;
}
.seat-west .bubble { top: 50%; left: calc(100% + 6px); margin-top: 0; transform: translateY(-50%); }
.seat-east .bubble { top: 50%; right: calc(100% + 6px); left: auto; margin-top: 0; transform: translateY(-50%); }
.seat-south .bubble { top: auto; bottom: calc(100% + 6px); margin-top: 0; }

@keyframes pop {
  from { transform: scale(.6); opacity: 0; }
}
.seat-west .bubble, .seat-east .bubble { animation: none; }

/* ---- Kitty & trick area ---- */

.kitty {
  position: absolute;
  left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 8px;
  z-index: 2;
}
.kitty-back { opacity: .85; }
.turned-down { opacity: .55; transform: rotate(90deg) scale(.9); }

.trick-area {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 200px; height: 180px;
  z-index: 2;
}

/* Each played card is anchored to the centre of the table and nudged toward
   the seat that played it, forming a tight diamond that never reaches the
   opponents' cards. --tx/--ty are the per-seat offsets from centre. */
.played-slot {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, 0px))) rotate(var(--rot, 0deg));
}
.played-slot .card { animation: playIn .22s ease-out; box-shadow: 0 3px 8px rgba(0,0,0,.45); }
.slot-0 { --ty: 52px; }                 /* South (you) */
.slot-2 { --ty: -52px; }                /* North (partner) */
.slot-1 { --tx: -58px; --rot: -6deg; }  /* West */
.slot-3 { --tx: 58px;  --rot: 6deg; }   /* East */

@keyframes playIn {
  from { transform: scale(1.25); opacity: .4; }
}

.table-msg {
  position: absolute;
  left: 50%; top: 68%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.72);
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 7;
  animation: pop .18s ease-out;
}

/* ---- Cards ---- */

.card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  background: #fdfdf6;
  color: #111;
  box-shadow: 0 2px 5px rgba(0,0,0,.35);
  flex: none;
}
.card.red { color: #d0302f; }

.card .corner {
  position: absolute;
  display: flex; flex-direction: column; align-items: center;
  line-height: 1;
}
.card .corner b { font-size: 15px; font-weight: 800; }
.card .corner i { font-style: normal; font-size: 13px; }
.card .corner.tl { top: 4px; left: 5px; }
.card .corner.br { bottom: 4px; right: 5px; transform: rotate(180deg); }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}

.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.16) 0 3px, transparent 3px 8px),
    linear-gradient(#a33c3c, #7a2222);
  box-shadow: inset 0 0 0 3px #fdfdf6, 0 2px 5px rgba(0,0,0,.35);
}

/* ---- Hand ---- */

.hand-hint {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  padding: 2px 0;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

.coach {
  margin: 4px 10px 0;
  padding: 9px 14px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.35;
  font-weight: 500;
  color: #eaf6ee;
  background: rgba(6, 30, 18, .82);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(243, 193, 75, .4);
}
.coach::before {
  content: "🎓";
  font-size: 16px;
  flex: none;
}

.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 8px 8px calc(20px + env(safe-area-inset-bottom));
  min-height: calc(var(--hand-card-h) + 34px);
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.4));
}

.hand .card {
  width: var(--hand-card-w);
  height: var(--hand-card-h);
  margin: 0 -9px;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.hand .card .corner b { font-size: 17px; }
.hand .card .pip { font-size: 34px; }

.hand .card.playable { cursor: pointer; }
.hand .card.playable:hover,
.hand .card.playable:active { transform: translateY(-14px); box-shadow: 0 8px 16px rgba(0,0,0,.5); z-index: 5; }
.hand .card.disabled { opacity: .45; }
.hand .card.suggested {
  box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0,0,0,.5);
  animation: suggestPulse 1.4s ease-in-out infinite;
}
@keyframes suggestPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0,0,0,.5); }
  50% { box-shadow: 0 0 0 3px var(--gold), 0 0 14px 4px rgba(243,193,75,.7), 0 6px 14px rgba(0,0,0,.5); }
}

/* ---- Bid panel ---- */

.panel {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hand-card-h) + 46px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
}
/* Lift the bid panel clear of the coach banner when coach mode is on. */
#screen-game.coach-on #bid-panel {
  bottom: calc(var(--hand-card-h) + 112px + env(safe-area-inset-bottom));
}
.panel {
  width: min(92vw, 340px);
  background: rgba(10, 24, 16, .94);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.15);
  padding: 14px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: pop .18s ease-out;
}

.panel-title { font-size: 17px; font-weight: 700; text-align: center; }

.panel-buttons { display: flex; gap: 10px; justify-content: center; }
.panel-buttons .btn { flex: 1; }

.suit-row { display: flex; gap: 8px; justify-content: center; }

.suit-btn {
  appearance: none;
  border: none;
  width: 54px; height: 54px;
  border-radius: 12px;
  font-size: 30px;
  background: #fdfdf6;
  color: #111;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,.4);
}
.suit-btn.red { color: #d0302f; }
.suit-btn:disabled { opacity: .3; cursor: default; }
.suit-btn.selected { box-shadow: 0 0 0 3px var(--gold), 0 2px 5px rgba(0,0,0,.4); transform: translateY(-3px); }

.alone-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 600;
}
.alone-row input { width: 20px; height: 20px; accent-color: var(--gold); }

/* ---- Overlay ---- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 30;
}

.overlay-card {
  width: min(90vw, 340px);
  background: linear-gradient(#123a24, #0b2716);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.15);
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
  animation: pop .2s ease-out;
}

.overlay-title { font-size: 24px; font-weight: 800; color: var(--gold); }
.overlay-body { font-size: 15px; line-height: 1.45; }
.overlay-card .panel-buttons { flex-direction: column; }
.score-line { margin-top: 10px; font-weight: 700; font-size: 16px; }

/* ============ Sub pages (settings / stats / help) ============ */

#screen-settings, #screen-stats, #screen-help {
  background: radial-gradient(120% 90% at 50% 0%, var(--felt-dark) 0%, #04220f 100%);
  overflow-y: auto;
}

.page {
  width: min(94vw, 440px);
  margin: 0 auto;
  padding: 14px 0 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-header { display: flex; align-items: center; gap: 12px; }
.page-header h2 { font-size: 24px; }

.settings-list, .stats-list {
  display: flex; flex-direction: column;
  background: rgba(0,0,0,.25);
  border-radius: 14px;
  overflow: hidden;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.setting:last-child { border-bottom: none; }
.setting > label { font-weight: 600; font-size: 15px; }
.setting > label small { display: block; font-weight: 400; opacity: .6; font-size: 12px; margin-top: 2px; }

.setting-toggle { flex-direction: row; align-items: center; justify-content: space-between; }

.toggle {
  appearance: none;
  width: 50px; height: 30px;
  border-radius: 15px;
  background: rgba(255,255,255,.2);
  position: relative;
  cursor: pointer;
  transition: background .15s;
  flex: none;
}
.toggle:checked { background: var(--gold); }
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: left .15s;
}
.toggle:checked::after { left: 23px; }

.segmented { display: flex; gap: 6px; }
.segmented button {
  flex: 1;
  appearance: none;
  border: none;
  padding: 10px 0;
  border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.segmented button.selected { background: var(--gold); color: #4a3403; }

.page-note { font-size: 12px; opacity: .55; text-align: center; }

.stat-row {
  display: flex; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 15px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row b { color: var(--gold); }

.help-body {
  background: rgba(0,0,0,.25);
  border-radius: 14px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.55;
  display: flex; flex-direction: column; gap: 10px;
}
.help-body h3 { color: var(--gold); font-size: 16px; margin-top: 6px; }
.help-body ul { padding-left: 20px; }

/* ============ Landscape / larger screens ============ */

@media (min-width: 700px) {
  :root {
    --card-w: 70px;
    --card-h: 100px;
    --hand-card-w: 78px;
    --hand-card-h: 112px;
  }
  .trick-area { width: 260px; height: 240px; }
  .slot-0 { --ty: 64px; }
  .slot-2 { --ty: -64px; }
  .slot-1 { --tx: -72px; }
  .slot-3 { --tx: 72px; }
  .hand .card { margin: 0 -4px; }
}

@media (max-height: 620px) {
  :root {
    --card-w: 48px;
    --card-h: 70px;
    --hand-card-w: 54px;
    --hand-card-h: 78px;
  }
  .avatar { width: 36px; height: 36px; font-size: 16px; }
  .menu-logo h1 { font-size: 40px; }
}
