/* How Five Banners looks around the 3D table: parchment panels with gold
   edges, the bar along the top, the card for a picked piece, and the
   buttons along the bottom. The colours are named here. */
:root {
  --ink: #2b1d10;
  --parchment: #f3e6c8;
  --parchment-dark: #e2cfa4;
  --gold: #c9a046;
  --wood: #2a1d14;
  --red: #c4362e;
  --glass: rgba(26, 18, 12, 0.78);
  --light: #f7ecd3;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--wood); color: var(--light); font: 16px/1.4 "Alegreya Sans", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; user-select: none; }
/* Pinching anywhere moves the table's view, never zooms the page (phones
   ignore user-scalable=no). Only long pages, like How to play, scroll. */
html, body { touch-action: none; }
.panel.wide, #recruit { touch-action: pan-y; }
#table { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

button {
  font: 700 16px "Alegreya Sans", system-ui, sans-serif; color: var(--ink);
  background: linear-gradient(#f6ead0, #dcc597); border: 2px solid var(--gold); border-radius: 10px;
  padding: 10px 18px; cursor: pointer; box-shadow: 0 3px 0 #8a6a2e, 0 4px 10px rgba(0,0,0,.35);
}
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6a2e; }
button.main { background: linear-gradient(#e2564b, #a52a22); color: #fff4dc; border-color: #f0c46a; box-shadow: 0 3px 0 #6d1712, 0 4px 10px rgba(0,0,0,.35); }
button:disabled { opacity: .45; cursor: default; }
button.icon { padding: 6px 12px; font-size: 20px; }
h1, h2, h3 { font-family: Cinzel, Georgia, serif; margin: 0 0 .4em; }

/* Full-screen panels: title, help, menu, the end. */
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(15, 10, 6, .55); padding: 16px; z-index: 10; }
#title { background: radial-gradient(ellipse at center, rgba(15,10,6,.15), rgba(15,10,6,.7)); }
.panel {
  background: linear-gradient(var(--parchment), var(--parchment-dark)); color: var(--ink);
  border: 3px solid var(--gold); border-radius: 16px; padding: 24px 26px; max-width: 460px; width: 100%;
  text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.6), inset 0 0 40px rgba(140,100,40,.25);
}
.panel.wide { max-width: 680px; max-height: 88vh; overflow-y: auto; text-align: left; }
.panel h1 { font-size: 46px; font-weight: 800; letter-spacing: 1px; color: #7a1c15; text-shadow: 0 2px 0 rgba(255,255,255,.5); }
.panel .tagline { font-style: italic; margin-top: -6px; }
.buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0 6px; }
.buttons.column { flex-direction: column; }
#title-banners { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
#title-banners img, .help-banner { width: 46px; height: 62px; object-fit: cover; border: 2px solid var(--gold); border-radius: 3px 3px 0 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%); }
#who { font-weight: 700; }
#stats { font-size: 14px; opacity: .8; }
.rounds { font-size: 15px; margin: 6px 0; }
.rounds select { font: 700 16px "Alegreya Sans", system-ui, sans-serif; color: var(--ink); background: #f6ead0; border: 2px solid var(--gold); border-radius: 8px; padding: 3px 6px; margin-left: 6px; }
.links a { color: #7a1c15; font-weight: 700; }
#help-classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
#help-classes div { background: rgba(255,255,255,.35); border-radius: 8px; padding: 6px 9px; font-size: 14px; }
#over-banner { width: 90px; height: 120px; object-fit: cover; border: 3px solid var(--gold); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%); }

/* The bar along the top. */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: linear-gradient(rgba(15,10,6,.85), rgba(15,10,6,0)); z-index: 5; }
#round { display: flex; flex-direction: column; line-height: 1.1; }
#round b { font-family: Cinzel, Georgia, serif; font-size: 18px; color: #ffd98a; }
#round span { font-size: 14px; opacity: .9; }
#timer { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font: 800 18px Cinzel, Georgia, serif; color: #fff4dc; background: conic-gradient(#e2b12c var(--left, 100%), rgba(255,255,255,.15) 0); }
#timer span { background: var(--wood); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
#timer.short span { color: #ff8a7a; }
#sides { margin-left: auto; display: flex; gap: 6px; }
.side-chip { display: flex; align-items: center; gap: 4px; background: var(--glass); border: 1px solid rgba(201,160,70,.6); border-radius: 8px; padding: 3px 7px 3px 3px; font-weight: 700; font-size: 14px; }
.side-chip img { width: 22px; height: 28px; object-fit: cover; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); }
.side-chip.out { opacity: .35; text-decoration: line-through; }
.side-chip.ready::after { content: "✓"; color: #8ef07a; margin-left: 2px; }
.side-chip.away { opacity: .6; font-style: italic; }
.side-chip.me { border-color: #ffd98a; box-shadow: 0 0 0 1px #ffd98a; }

/* The card for a picked piece. */
#card { position: fixed; left: 12px; bottom: calc(84px + var(--safe-bottom)); width: 290px; background: linear-gradient(var(--parchment), var(--parchment-dark)); color: var(--ink); border: 2px solid var(--gold); border-radius: 12px; padding: 10px 12px; z-index: 6; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
#card-head { display: flex; gap: 10px; align-items: center; }
#card-head img { width: 34px; height: 44px; object-fit: cover; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); }
#card-head b { font-family: Cinzel, Georgia, serif; font-size: 19px; display: block; }
#card-head span { font-size: 13px; opacity: .8; }
#card-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 8px 0 4px; text-align: center; }
#card-stats div { background: rgba(255,255,255,.4); border-radius: 6px; padding: 2px 0; font-size: 12px; }
#card-stats b { display: block; font-size: 16px; }
#card-about { margin: 6px 0; font-size: 14px; }
#card-buttons { display: flex; gap: 8px; }
#card-buttons button { padding: 6px 12px; font-size: 14px; }

/* The buttons along the bottom. */
#actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 12px 12px calc(14px + var(--safe-bottom)); background: linear-gradient(rgba(15,10,6,0), rgba(15,10,6,.85)); z-index: 5; }
#points { display: flex; align-items: center; gap: 4px; background: var(--glass); border: 1px solid var(--gold); border-radius: 20px; padding: 6px 12px; font: 800 18px Cinzel, Georgia, serif; color: #ffd98a; }
#ready-button { min-width: 120px; }

#recruit { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--safe-bottom)); width: min(560px, calc(100% - 24px)); background: linear-gradient(var(--parchment), var(--parchment-dark)); color: var(--ink); border: 2px solid var(--gold); border-radius: 12px; padding: 10px 12px; z-index: 7; }
#recruit h3 { font-size: 17px; }
#recruit small { font-family: "Alegreya Sans", sans-serif; font-weight: 400; font-size: 13px; opacity: .8; }
#recruit-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#recruit-list button { padding: 6px 4px; font-size: 14px; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
#recruit-list button small { font-weight: 400; }
#recruit-list button.picked { outline: 3px solid #2f6fd6; }

#army { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 24px)); max-height: calc(100% - 140px); display: flex; flex-direction: column; background: linear-gradient(var(--parchment), var(--parchment-dark)); color: var(--ink); border: 2px solid var(--gold); border-radius: 12px; padding: 12px 14px; z-index: 7; touch-action: pan-y; }
#army h3 { font-size: 18px; margin-bottom: 6px; }
#army small { display: block; font-family: "Alegreya Sans", sans-serif; font-weight: 400; font-size: 14px; opacity: .8; }
#army-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.army-row { display: grid; grid-template-columns: 1fr auto 2.2em auto; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(43,29,16,.15); }
.army-row span { line-height: 1.1; }
.army-row span small { font-size: 12px; }
.army-row b { text-align: center; font-size: 18px; }
.army-row button { width: 40px; height: 36px; padding: 0; font-size: 22px; }
#army-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
#army-count { font: 700 18px Cinzel, Georgia, serif; }
#army-count.short { color: #a3261e; }

#toast { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); background: var(--glass); border: 2px solid var(--gold); color: #fff4dc; padding: 8px 18px; border-radius: 10px; font: 700 18px Cinzel, Georgia, serif; z-index: 8; text-align: center; max-width: calc(100% - 24px); pointer-events: none; }

@media (max-width: 640px) {
  #hud { flex-wrap: wrap; gap: 8px; }
  #sides { margin-left: 0; width: 100%; justify-content: space-between; order: 3; }
  .side-chip { font-size: 12px; padding-right: 5px; }
  #card { left: 8px; right: 8px; width: auto; bottom: calc(76px + var(--safe-bottom)); }
  #recruit-list { grid-template-columns: repeat(4, 1fr); }
  .panel h1 { font-size: 36px; }
  #toast { top: 108px; font-size: 15px; }
}

/* Playing online. */
.join { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.join input { font: 700 24px Cinzel, serif; width: 6.5em; text-align: center; letter-spacing: 6px; text-transform: uppercase; padding: 6px 8px; border-radius: 8px; border: 2px solid #c9a046; background: #fff8e8; color: #3a2414; }
.message { min-height: 1.3em; font-weight: 700; color: #8a1c14; }
.code { letter-spacing: 4px; color: #7a1c15; }
#seats { list-style: none; padding: 0; margin: 12px auto; display: grid; gap: 6px; max-width: 340px; text-align: left; }
#seats li { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,.35); }
#seats li.bot { opacity: .6; font-style: italic; }
#seats li.you { box-shadow: 0 0 0 2px #c9a046; }
#seats img { width: 26px; height: 34px; object-fit: cover; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); }
#seats small { margin-left: auto; opacity: .75; }
