/* A little room for the island's new neighbours. */
:root {
  --online-ink: #354f3e;
  --online-muted: #64745b;
  --online-line: #d8dfc5;
  --online-shadow: 0 14px 48px #29473426, 0 4px 0 #fffbed80;
}

.account-shade, .chat-panel, .online-game, .social-bar, .profile-button {
  color: var(--online-ink);
}
.account-shade button, .chat-panel button, .online-game button,
.social-action, .profile-button {
  touch-action: manipulation;
}
.account-shade :focus-visible, .chat-panel :focus-visible,
.online-game :focus-visible, .social-action:focus-visible, .profile-button:focus-visible {
  outline: 3px solid #a94468;
  outline-offset: 3px;
}
.account-shade input, .chat-panel input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #a7b69a;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fffef8;
  color: var(--online-ink);
  font: inherit;
  font-size: 16px;
}
.account-shade input::placeholder, .chat-panel input::placeholder { color: #74806c; opacity: 1; }
.account-shade .primary, .online-game .primary {
  min-height: 48px;
  background: #537a50;
  box-shadow: 0 4px 0 #385b3b;
}
.account-shade .primary:hover, .online-game .primary:hover { background: #456d45; }
.account-shade .secondary, .chat-panel .secondary, .online-game > .secondary {
  min-height: 44px;
  color: #426342;
  border-color: #bacaa9;
}
.account-shade button:disabled, .online-game button:disabled { opacity: .55; transform: none; }

/* Accounts stay usable with a short viewport or an on-screen keyboard. */
.account-shade {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  background: #294d465c;
  backdrop-filter: blur(8px);
}
.account-card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 30px;
  border: 2px solid #fffef7;
  border-radius: 16px 36px 16px 36px;
  background: var(--cream);
  box-shadow: var(--online-shadow);
  scrollbar-width: thin;
  scrollbar-color: #a7b69a transparent;
}
.account-card .eyebrow { color: #627b50; font-size: 10px; line-height: 1.5; }
.account-card h2 { margin: 10px 0 12px; font-size: 29px; line-height: 1.15; letter-spacing: -.7px; overflow-wrap: anywhere; }
.account-card p { margin: 0 0 18px; color: var(--online-muted); font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.account-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px;
  margin: 18px 0 20px;
  border: 1px solid var(--online-line);
  border-radius: 15px;
  background: #edf0df;
}
.account-tabs button {
  min-height: 44px;
  padding: 9px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #526747;
  font-size: 13px;
  font-weight: 700;
}
.account-tabs button.selected { background: #fffdf3; color: #354f3e; box-shadow: 0 2px 5px #42583a14; }
.account-card form { display: grid; gap: 15px; }
.account-card label { display: grid; gap: 7px; color: #435a3d; font-size: 13px; font-weight: 700; }
.account-card .account-error { margin: 0; color: #a22f4b; font-size: 13px; font-weight: 600; }
.account-error:empty { display: none; }
.account-card form > button, .account-card > button { width: 100%; }
.account-card > button { margin-top: 14px; }
.account-card > small { display: block; margin-top: 16px; color: #68775e; font-size: 11px; line-height: 1.6; }

.profile-button {
  max-width: 160px;
  min-height: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 11px 17px;
  border: 1px solid #fffbed;
  border-radius: 24px;
  background: #f9e5dff5;
  box-shadow: 0 4px 0 #52715715;
  font-size: 13px;
  font-weight: 800;
}
.profile-button::before { content: '\2661'; margin-right: 7px; color: #a9536a; font-size: 17px; }
.profile-button:hover { background: #fff0ec; }
.social-bar {
  position: fixed;
  z-index: 11;
  top: 100px;
  right: 32px;
  display: flex;
  gap: 5px;
  padding: 6px;
  border: 1px solid #fffcead9;
  border-radius: 19px;
  background: #fffbedeb;
  box-shadow: 0 5px 18px #36523916;
}
.social-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: #eaf0da;
  color: #456443;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.social-action:nth-child(-n+4) { padding: 6px; font-family: "Segoe UI Symbol", "Segoe UI Emoji", sans-serif; font-size: 23px; }
.social-action:nth-child(4) { color: #a84463; background: #f7e2dd; }
.social-action:hover { background: #dce7c7; }
.social-action:active { transform: translateY(2px); }

/* Chat opens above the map and the touch controls. */
.chat-panel {
  position: fixed;
  z-index: 17;
  top: 168px;
  right: 32px;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  height: min(330px, calc(100dvh - 380px));
  min-height: 150px;
  padding: 14px;
  border: 2px solid #fffef4;
  border-radius: 22px 9px 22px 22px;
  background: #fffbedf7;
  box-shadow: var(--online-shadow);
}
.chat-header { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 10px; padding-bottom: 9px; border-bottom: 1px dashed #cbd7bc; }
.chat-header b { font-size: 17px; }
.chat-header > span { grid-column: 1; font-size: 11px; color: #627851; }
.chat-header .plain-close { grid-column: 2; grid-row: 1 / 3; }
.plain-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #e9edda;
  color: #496446;
  font-size: 27px;
  line-height: 1;
}
.plain-close:hover { background: #d9e2c6; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 9px 2px; }
.chat-messages:empty::before { content: 'Un saludo puede ser el principio de una amistad.'; display: block; padding: 10px 0; font-size: 13px; line-height: 1.6; color: #697860; }
.chat-messages p { margin: 0 0 10px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-messages b { color: #7a4b65; }
.chat-panel form { display: flex; flex-shrink: 0; gap: 7px; padding-top: 8px; }
.chat-panel input { min-height: 44px; padding: 9px 10px; font-size: 16px; }
.chat-panel form button { padding: 10px 12px; }

/* Tables are independent little windows; the close button stays in reach. */
.online-game {
  position: fixed;
  z-index: 24;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  width: min(486px, calc(100vw - 28px));
  max-height: calc(100dvh - 284px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #a7b69a transparent;
  padding: 0 22px 22px;
  border: 2px solid #fffef6;
  border-radius: 26px 12px 26px 12px;
  background: var(--cream);
  box-shadow: 0 18px 75px #26463545;
}
.game-heading { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 10px; background: var(--cream); }
.game-heading h2 { margin: 0; font-size: 23px; line-height: 1.2; letter-spacing: -.5px; }
.online-game > p { font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.game-players { margin: 4px 0 10px; color: #78617b; font-size: 13px !important; font-weight: 700; }
.game-status { padding: 10px 13px; margin: 8px 0; border-radius: 12px; background: #e9efd8; color: #435c3b; font-weight: 700; }
.game-status:empty { display: none; }
.online-game .table-note { display: block; margin: 10px 0 14px; font-size: 12px; line-height: 1.6; color: #66745c; }
.online-game > button { margin: 6px 6px 5px 0; max-width: 100%; vertical-align: middle; font-size: 13px; }
.online-game > .primary { padding: 12px 16px; }

.chessboard {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  width: min(100%, 400px);
  aspect-ratio: 1;
  margin: 14px auto;
  overflow: hidden;
  border: 4px solid #587154;
  border-radius: 9px;
  box-shadow: 0 5px 0 #d6dbc6;
}
.chess-square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-family: "Segoe UI Symbol", "DejaVu Sans", serif;
  font-size: clamp(27px, 7.8vw, 40px);
  font-weight: 400;
  line-height: 1;
  isolation: isolate;
}
.chess-square.light { background: #f1ebd0; }
.chess-square.dark { background: #87a57d; }
.chess-square.piece-w { color: #fffdf5; text-shadow: -1px -1px 0 #314333, 1px -1px 0 #314333, -1px 1px 0 #314333, 1px 1px 0 #314333, 0 2px 1px #314333; }
.chess-square.piece-b { color: #243d30; text-shadow: 0 1px 0 #fffce998; }
.chess-square:hover { box-shadow: inset 0 0 0 3px #34583b8c; }
.chess-square.selected { background: #f0cc8e; box-shadow: inset 0 0 0 3px #ad6f3e; }
.chess-square.possible::after { content: ''; position: absolute; width: 25%; height: 25%; border-radius: 50%; background: #37584180; pointer-events: none; }
.chess-square.possible[class*="piece-"]::after { inset: 3px; width: auto; height: auto; border: 3px solid #915a48; background: transparent; }
.chess-square:focus-visible { z-index: 1; outline-offset: -4px; }

.poker-players { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.poker-players span { max-width: 100%; padding: 8px 10px; border: 1px solid #d6ddc7; border-radius: 11px; background: #f0f1e2; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.poker-players .current { background: #e6edce; border-color: #8b9f6d; color: #3c5839; font-weight: 800; }
.poker-players .current::before { content: '\25CF'; display: inline-block; margin-right: 6px; color: #52774b; font-size: 9px; }
.poker-pot { padding: 17px; border: 1px dashed #aaa980; border-radius: 15px; background: #f7ebc9; color: #746035; text-align: center; font-size: 20px; font-weight: 800; }
.poker-hand { display: flex; justify-content: center; gap: 8px; padding: 14px 0 7px; margin: 10px 0; }
.playing-card { display: grid; place-items: center; flex: 0 1 68px; min-width: 0; height: 94px; padding: 0 3px; border: 1px solid #bbc5ae; border-radius: 10px; background: #fffef7; color: #314636; box-shadow: 0 4px 0 #ccd5bf; font: 800 clamp(21px, 6vw, 27px)/1 "Segoe UI Symbol", "Segoe UI", sans-serif; }
.playing-card.red { color: #ba3d59; }
.playing-card:hover { border-color: #8a9d76; background: #fff; }
.playing-card.picked { transform: translateY(-9px); border: 2px solid #b85775; background: #fff0ee; box-shadow: 0 4px 0 #d5a6ad; }

@media (max-width: 1100px) and (min-width: 601px) {
  .top-right { gap: 8px; }
  .top-right .weather { display: none; }
  .profile-button { max-width: 125px; }
  .social-bar { right: 19px; top: 92px; }
  .chat-panel { right: 19px; top: 158px; }
}
@media (max-width: 600px) {
  .profile-button { position: absolute; right: 0; top: 51px; min-height: 42px; max-width: 172px; padding: 8px 13px; font-size: 12px; }
  .social-bar { top: 116px; right: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 174px; gap: 4px; padding: 6px; border-radius: 16px 6px 16px 16px; }
  .social-action { min-width: 0; min-height: 44px; padding: 7px 4px; font-size: 11px; border-radius: 9px; }
  .social-action:nth-child(-n+4) { font-size: 23px; }
  .social-action:last-child { grid-column: 1 / -1; min-height: 40px; }
  .chat-panel { top: 278px; right: 12px; width: calc(100vw - 24px); height: min(272px, calc(100dvh - 574px)); min-height: 160px; padding: 11px 12px; }
  .chat-header { padding-bottom: 6px; }
  .chat-messages p { margin-bottom: 7px; }
  .online-game { top: max(75px, env(safe-area-inset-top)); max-height: calc(100dvh - 265px); padding: 0 14px 18px; border-radius: 20px 9px 20px 9px; }
  .game-heading { padding-top: 12px; gap: 8px; }
  .game-heading h2 { font-size: 21px; }
  .online-game > p { font-size: 13px; }
  .game-status { padding: 9px 11px; }
  .chessboard { border-width: 3px; }
  .poker-hand { gap: 6px; }
  .playing-card { flex-basis: 58px; height: 83px; border-radius: 8px; }
  .account-shade { padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  .account-card { padding: 25px 22px; border-radius: 15px 30px 15px 30px; }
  .account-card h2 { font-size: 28px; }
  .account-card p { font-size: 13px; }
}
@media (max-width: 360px) {
  .social-bar { width: 151px; right: 8px; }
  .social-action { font-size: 10px; }
  .profile-button { right: -2px; max-width: 147px; }
  .account-card { padding: 22px 16px; }
  .chess-square { font-size: 27px; }
  .playing-card { height: 74px; font-size: 22px; }
}
@media (max-height: 700px) {
  .online-game { top: 68px; max-height: calc(100dvh - 205px); }
  .chat-panel { top: 164px; height: calc(100dvh - 330px); min-height: 150px; }
  .account-card { padding-top: 21px; padding-bottom: 21px; }
  .account-card form { gap: 11px; }
  .account-tabs { margin: 13px 0; }
}
@media (max-height: 500px) and (min-width: 601px) {
  .online-game { top: 12px; max-height: calc(100dvh - 24px); }
  .social-bar { top: 80px; }
  .chat-panel { top: 142px; height: calc(100dvh - 158px); }
}
@media (prefers-reduced-motion: reduce) {
  .social-action:active, .playing-card.picked, .account-shade .primary:hover, .online-game .primary:hover { transform: none; }
}
