:root {
  color-scheme: light;
  font-family: system-ui, "Malgun Gothic", sans-serif;
  color: #30261e;
  background: #e3f0e5;
}
* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(#c9e8fa, #f9f1d7 55%, #e3f0e5); min-height: 100vh; }
main { width: min(100%, 940px); margin: auto; padding: 10px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); }
.status { min-height: 1.4rem; text-align: center; font-size: .87rem; margin-bottom: 5px; }
.game {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(11, minmax(47px, 1fr));
  gap: 4px;
  padding: 7px;
  border: 2px solid #b07d34;
  border-radius: 18px;
  background: #f1d28a;
  box-shadow: 0 6px 20px #6d512332;
}
.tile {
  position: relative;
  display: grid;
  place-content: center;
  justify-items: center;
  min-width: 0;
  padding: 3px;
  border: 1px solid #8254396e;
  border-radius: 8px;
  color: #30261e;
  background: var(--tile, #fdf0d4);
  text-align: center;
  line-height: 1.1;
  box-shadow: inset 0 0 0 2px #ffffff9c;
}
.tile small { position: absolute; top: 4px; left: 5px; font-weight: 700; }
.tile b { font-size: .77rem; }
.tile-icon { font-size: 1.22rem; }
.tile[aria-current="location"] { outline: 3px solid #174772; outline-offset: -3px; }
.token {
  position: absolute;
  width: clamp(19px, 4vw, 35px);
  height: clamp(19px, 4vw, 35px);
  border: 2px solid #164b73;
  border-radius: 50%;
  object-fit: cover;
  right: -3px;
  top: -4px;
  box-shadow: 0 2px 4px #0005;
  z-index: 1;
}
.dashboard { grid-area: 2 / 2 / 11 / 7; min-width: 0; background: #fff6df; border-radius: 12px; overflow: hidden; border: 1px solid #c69a54; }
.banner { height: clamp(100px, 19vw, 142px); background: #a5dcf6 url("banner.webp") center / cover no-repeat; }
.dashboard-body { padding: 10px; display: grid; gap: 9px; }
.overview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.profile { display: flex; gap: 7px; align-items: center; overflow-wrap: anywhere; }
.profile img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
#career { font-size: .82rem; }
#stats { flex: 1 1 225px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 0; }
#stats div { padding: 4px; border-radius: 6px; background: #f1e0c1; text-align: center; overflow-wrap: anywhere; }
dt { font-size: .73rem; } dd { margin: 2px 0; font-size: .85rem; font-weight: 750; }
.turn { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px 13px; align-items: center; }
.dice { color: #133c60; font-size: 2.5rem; line-height: 1; white-space: nowrap; }
#turn-status { min-width: 5.5rem; font-size: .83rem; }
button, input, select { font: inherit; }
button, .button-link {
  cursor: pointer;
  border: 1px solid #ac804a;
  border-radius: 8px;
  padding: .5em .75em;
  color: #36251b;
  background: linear-gradient(#fff9eb, #f2d7aa);
  font-weight: 700;
}
button:hover:not(:disabled), .button-link:hover { filter: brightness(1.045); border-color: #78501d; }
button:active:not(:disabled), .button-link:active { transform: translateY(1px); }
button:focus-visible, .button-link:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #17649c; outline-offset: 2px; }
button:disabled { cursor: default; opacity: .6; }
.primary { background: linear-gradient(#ffe995, #f7ac39); box-shadow: inset 0 0 0 2px #ffefbc; }
#facilities { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
#facilities button { display: grid; justify-items: center; gap: 2px; padding: 4px 1px; font-size: .82rem; }
#facilities img { width: min(100%, 48px); height: 30px; object-fit: cover; border-radius: 4px; }
.event-box { border: 1px solid #d3ac72; border-radius: 8px; background: #fffaf0; overflow: hidden; }
.event-box h2 { margin: 0; padding: 4px 8px; background: #855632; color: white; font-size: .86rem; }
#log { margin: 0; height: 67px; overflow-y: auto; padding: 4px 8px 4px 25px; font-size: .83rem; }
#log li + li { margin-top: 3px; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }
.save-bar { display: flex; gap: 6px; flex-wrap: wrap; }
dialog { max-width: min(580px, calc(100% - 22px)); width: 100%; max-height: 90dvh; border: 2px solid #af7b39; border-radius: 13px; background: #fff7e7; color: inherit; padding: 14px; }
dialog::backdrop { background: #172b40a0; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-header h2 { font-size: 1.25rem; margin: 0; }
#modal-status { min-height: 1.2em; margin-bottom: 0; font-size: .9rem; }
#modal-body form { display: flex; flex-wrap: wrap; align-items: end; gap: 7px; margin: .6em 0; }
#modal-body label { display: grid; gap: 3px; min-width: 0; font-size: .9rem; }
input, select { min-width: 0; max-width: 100%; border: 1px solid #a47e54; border-radius: 5px; background: #fff; padding: 6px; }
input[type=number] { width: 8em; }
#modal-body h3 { margin: 1em 0 .3em; font-size: 1rem; }
#modal-body p { margin: .6em 0; }
.card-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-options { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; }
.avatar-option > span { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 3px 6px; border: 2px solid #ebdec4; border-radius: 10px; cursor: pointer; background: #fdf5e8; text-align: center; font-size: .73rem; font-weight: 700; }
.avatar-option img { width: 100%; height: clamp(48px, 8.5vw, 85px); object-fit: contain; }
.avatar-option input:checked + span { border-color: #236a98; background: #e8f4ff; box-shadow: inset 0 0 0 1px #c5e2fb; }
.avatar-option input:focus-visible + span { outline: 3px solid #17649c; outline-offset: 2px; }

.avatar-picker { flex: 1 0 100%; min-width: 0; margin: 0; padding: 0; border: 0; }
.avatar-picker legend { margin-bottom: 7px; font-weight: 700; }
.avatar-picker .avatar-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#modal-body .avatar-option { display: block; }
.event-art { width: 130px; border-radius: 8px; margin-top: 10px; }
@media (max-width: 620px) {
  main { padding: 6px; }
  .avatar-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .avatar-option img { height: 62px; }
  .game { grid-template-rows: repeat(11, 32px) auto; gap: 3px; padding: 5px; }
  .dashboard { grid-area: 12 / 1 / 13 / 8; }
  .game::before { content: ""; grid-area: 2 / 2 / 11 / 7; background: #fff6df url("banner.webp") center / contain no-repeat; border-radius: 8px; }
  .banner { display: none; }
  .tile { grid-template-rows: 13px auto; padding: 1px; }
  .tile small { top: 1px; left: 2px; font-size: .58rem; }
  .tile-icon { font-size: .76rem; }
  .tile b { font-size: .56rem; overflow-wrap: anywhere; }
}
