/* Mordi v0.4.1 -- deliberately compatible with Safari on iOS 9. No CSS grid or custom properties. */
* { box-sizing: border-box; }
html { background: #10151b; }
body { margin: 0; min-width: 320px; background: #10151b; color: #f2f0e9; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; }
button { -webkit-appearance: none; appearance: none; cursor: pointer; border: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { opacity: .32; cursor: default; }
button:focus, input:focus, select:focus { outline: 2px solid #bfeb86; outline-offset: 2px; }
.app { min-height: 100vh; min-height: 100%; padding: 15px 20px 12px; margin: 0 auto; max-width: 1400px; }
.header, .brand, .header-actions, .control-strip, .game-metric, .player-top, .life-row, .player-meta, .footer, .dialog-head, .counter-row, .status-row, .tool-buttons, .actions-row, .player-name-line { display: -webkit-flex; display: flex; }
.header { height: 62px; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.brand { align-items: center; }
.brand-icon { width: 43px; height: 43px; border: 2px solid #c5eb8d; border-radius: 13px; line-height: 38px; text-align: center; font-weight: 900; font-size: 25px; color: #c5eb8d; background: #1f2a26; transform: rotate(-7deg); }
.brand-copy { padding-left: 13px; }
.brand-title { letter-spacing: 2.5px; font-size: 26px; line-height: 28px; font-weight: 900; }
.brand-period { color: #c5eb8d; }
.brand-subtitle { color: #8e9b9e; font-size: 9px; font-weight: 800; letter-spacing: 1.9px; margin-top: 3px; }
.header-actions { align-items: center; }
.header-actions > * { margin-left: 9px; }
.save-status { letter-spacing: 1.1px; color: #a8cba1; font-size: 10px; font-weight: 700; padding-right: 10px; }
.btn { white-space: nowrap; border-radius: 11px; font-weight: 800; font-size: 12px; letter-spacing: .7px; min-height: 44px; padding: 10px 16px; }
.btn-outline { background: #202832; color: #cfd8d8; border: 1px solid #36444e; }
.btn-outline:active { background: #34424c; }
.btn-accent { background: #c5eb8d; color: #162015; border: 1px solid #c5eb8d; }
.btn-accent:active { background: #a6cf71; }
.btn-danger { color: #ffc2be; background: #492e32; border: 1px solid #754b50; }
.control-strip { border: 1px solid #2d3944; background: #18212a; border-radius: 17px; min-height: 79px; align-items: center; padding: 10px 16px; margin-bottom: 14px; }
.game-metric { flex-direction: column; -webkit-flex-direction: column; justify-content: center; }
.metric-label { color: #889aa2; font-size: 10px; font-weight: 800; letter-spacing: 1.6px; margin-bottom: 3px; }
.metric-number { font-size: 29px; line-height: 30px; }
.metric-player { font-size: 18px; line-height: 26px; color: #dcf7b4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider-vertical { height: 42px; width: 1px; background: #394752; margin: 0 24px; }
.active-metric { flex: 1; -webkit-flex: 1; min-width: 80px; }
.next-turn { margin-right: 9px; }
.next-turn .nav-arrow { font-size: 17px; margin-left: 7px; }
.players { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -6px; }
.player-card { position: relative; width: -webkit-calc(50% - 12px); width: calc(50% - 12px); margin: 0 6px 12px; background: #1c2630; border: 1px solid #34414e; border-top: 4px solid #6a9bd5; border-radius: 17px; overflow: hidden; min-height: 219px; padding: 12px 14px 11px; }
.player-card.is-active { background: #22303b; border-left-color: #6f8b62; border-right-color: #6f8b62; border-bottom-color: #6f8b62; box-shadow: inset 0 0 0 1px #627b5e; }
.player-card.is-out { opacity: .55; }
.player-card.is-out .life-number { color: #ff9d97; }
.player-top { justify-content: space-between; align-items: center; min-height: 33px; }
.player-name-line { align-items: center; min-width: 0; }
.player-dot { display: inline-block; flex: none; -webkit-flex: none; width: 11px; height: 11px; border-radius: 50%; margin-right: 9px; }
.player-name { font-weight: 850; font-size: 17px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.player-badges { padding-left: 10px; white-space: nowrap; }
.tiny-badge { font-size: 9px; font-weight: 900; letter-spacing: .3px; background: #344434; color: #d5f1b6; border-radius: 5px; padding: 4px 6px; margin-left: 5px; }
.tiny-badge.out { background: #633d40; color: #ffd3d1; }
.detail-trigger { border: 1px solid #42505d; background: #2a3541; color: #d4dddd; border-radius: 9px; min-height: 36px; padding: 0 12px; font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.detail-trigger:active { background: #3a4a58; }
.life-row { justify-content: space-between; align-items: center; margin-top: 8px; }
.life-btn { color: #f4f1e6; background: #35414e; width: 49px; height: 58px; border-radius: 12px; font-size: 29px; line-height: 50px; font-weight: 400; flex: none; -webkit-flex: none; }
.life-btn:active { background: #556674; }
.life-btn.five { width: 41px; height: 45px; font-size: 16px; font-weight: 800; color: #abbcc4; background: #29343f; }
.life-btn.five:active { background: #485967; }
.life-display { text-align: center; flex: 1; -webkit-flex: 1; min-width: 60px; margin: 0 3px; }
.life-number { font-size: 76px; line-height: 78px; font-weight: 850; letter-spacing: -3.5px; font-variant-numeric: tabular-nums; }
.life-caption { display: block; color: #8fa1aa; font-size: 9px; font-weight: 850; letter-spacing: 2.2px; margin-top: -1px; }
.player-meta { margin-top: 11px; border-top: 1px solid #35424c; padding-top: 10px; align-items: center; justify-content: space-between; }
.meta-pair { color: #8fa0a9; font-size: 10px; font-weight: 800; letter-spacing: .8px; }
.meta-pair strong { color: #eff1e9; font-size: 14px; margin-left: 6px; }
.turn-pill { color: #dcf7b2; background: #37513d; padding: 6px 9px; border-radius: 20px; font-size: 9px; font-weight: 900; letter-spacing: .9px; }
.turn-pill.waiting { background: #293540; color: #768995; }
.footer { padding: 0 4px; min-height: 30px; align-items: center; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.footer-item { margin: 0 20px 7px 0; font-size: 10px; font-weight: 800; letter-spacing: .7px; color: #8598a1; }
.footer-item strong { color: #d5e0da; margin-left: 6px; }
.footer-icon { color: #c5eb8d; margin-right: 3px; font-size: 15px; }
.footer-tip { color: #6f828d; font-size: 11px; flex: 1; -webkit-flex: 1; text-align: right; margin-bottom: 7px; }
.offline-status { font-size: 9px; font-weight: 800; color: #7c969f; letter-spacing: .6px; margin-left: 14px; margin-bottom: 7px; }
.dialog-backdrop { position: fixed; z-index: 30; top: 0; left: 0; right: 0; bottom: 0; background: rgba(3,8,13,.82); display: -webkit-flex; display: flex; align-items: center; justify-content: center; padding: 16px; }
.hidden { display: none !important; }
.dialog { background: #1c2630; border: 1px solid #50606a; border-radius: 20px; width: 630px; max-width: 100%; max-height: 94vh; overflow-y: auto; -webkit-overflow-scrolling: touch; box-shadow: 0 22px 70px rgba(0,0,0,.65); padding: 20px 24px 22px; }
.dialog-head { align-items: flex-start; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid #384550; margin-bottom: 14px; }
.eyebrow { font-size: 10px; color: #b6db8e; letter-spacing: 1.7px; font-weight: 900; }
.dialog-title { font-size: 25px; margin: 4px 0 0; letter-spacing: -.5px; }
.icon-close { min-width: 44px; min-height: 44px; background: #303c48; border-radius: 11px; color: #e9eeee; font-size: 27px; line-height: 40px; }
.dialog-section { margin-top: 18px; }
.dialog-section h3 { color: #dce6df; font-size: 12px; font-weight: 900; letter-spacing: 1.2px; margin: 0 0 9px; }
.dialog-note { font-size: 12px; color: #91a2ab; line-height: 1.5; margin: 6px 0 13px; }
.counter-row { justify-content: space-between; align-items: center; border: 1px solid #364653; border-radius: 13px; background: #242f39; padding: 9px 11px; margin-top: 8px; min-height: 57px; }
.counter-name { font-size: 13px; font-weight: 750; }
.counter-sub { font-size: 10px; color: #899ba3; margin-top: 3px; }
.counter-control { display: -webkit-flex; display: flex; align-items: center; }
.counter-control button { height: 39px; width: 40px; border-radius: 9px; background: #3c4c58; color: white; font-size: 23px; }
.counter-control button:active { background: #566976; }
.counter-control strong { min-width: 45px; text-align: center; font-size: 21px; font-variant-numeric: tabular-nums; }
.status-row { margin-top: 7px; }
.status-row .status-button { width: 50%; margin-right: 7px; min-height: 49px; border-radius: 11px; background: #303d49; color: #adbbc2; font-size: 12px; font-weight: 800; }
.status-row .status-button:last-child { margin: 0; }
.status-row .status-button.selected { background: #365440; color: #e0fac5; border: 1px solid #89aa7b; }
.status-row .status-button:active { background: #52616b; }
.field-label { display: block; color: #acb9c0; font-size: 11px; font-weight: 900; letter-spacing: 1px; margin: 12px 0 5px; }
.form-select, .form-input { -webkit-appearance: none; appearance: none; width: 100%; height: 45px; border: 1px solid #465865; border-radius: 10px; background: #2a3642; padding: 0 12px; color: #f0f4ef; font-size: 16px; }
.name-fields { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -5px; }
.name-field { width: 50%; padding: 0 5px; }
.name-field .field-label { margin-top: 8px; }
.name-field .form-input { height: 43px; }
.actions-row { margin-top: 21px; }
.actions-row .btn { margin-right: 9px; }
.actions-row .btn:last-child { margin-right: 0; }
.tool-buttons { -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 15px -5px; }
.tool-buttons .btn { flex: 1; -webkit-flex: 1; margin: 5px; min-width: 126px; height: 58px; }
.roll-result { text-align: center; background: #111b22; border: 1px dashed #485b63; padding: 20px 12px; border-radius: 13px; }
.roll-result .roll-label { color: #97acae; letter-spacing: 1px; font-size: 11px; font-weight: 850; }
.roll-result .roll-value { color: #d9f5b7; font-size: 33px; font-weight: 900; margin-top: 4px; }
.toast { position: fixed; z-index: 45; left: 50%; bottom: 22px; -webkit-transform: translateX(-50%); transform: translateX(-50%); text-align: center; background: #c6eb92; color: #122018; border-radius: 10px; padding: 12px 18px; font-size: 12px; font-weight: 850; box-shadow: 0 9px 20px rgba(0,0,0,.45); max-width: 90%; }
@media (max-width: 840px) {
  .app { padding: 10px 12px; }
  .save-status { display: none; }
  .divider-vertical { margin: 0 15px; }
  .player-card { padding: 11px 11px 9px; min-height: 208px; }
  .life-btn { width: 42px; }
  .life-btn.five { width: 34px; font-size: 14px; }
  .life-number { font-size: 64px; line-height: 70px; }
  .footer-tip { display: none; }
}
@media (max-width: 600px) {
  .brand-subtitle, .wide-label, .tools-button { display: none; }
  .brand-icon { width: 37px; height: 37px; line-height: 33px; font-size: 21px; }
  .brand-title { font-size: 21px; }
  .header { height: 55px; }
  .btn { padding: 9px 12px; }
  .control-strip { padding: 9px; min-height: 70px; }
  .metric-player { font-size: 14px; }
  .metric-label { font-size: 9px; }
  .divider-vertical { margin: 0 10px; }
  .next-turn { padding: 9px; font-size: 10px; margin-right: 0; }
  .players { display: block; }
  .player-card { width: auto; min-height: 215px; }
  .life-number { font-size: 76px; }
  .life-btn { width: 53px; }
  .life-btn.five { width: 43px; }
  .dialog { padding: 16px; }
  .footer-item { font-size: 9px; }
}
@media (orientation: landscape) and (max-height: 720px) and (min-width: 700px) {
  .header { height: 54px; margin-bottom: 7px; }
  .control-strip { min-height: 64px; margin-bottom: 8px; }
  .player-card { min-height: 186px; margin-bottom: 8px; padding-top: 8px; padding-bottom: 8px; }
  .life-row { margin-top: 0; }
  .life-number { font-size: 60px; line-height: 66px; }
  .life-btn { height: 52px; }
  .player-meta { margin-top: 6px; padding-top: 6px; }
}

/* Mordi v0.2: optional per-turn countdown; simple layout for legacy Safari. */
.turn-timer { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  border: 1px solid #516f51; border-radius: 11px; background: #223b36; padding: 5px 7px;
  margin-top: 9px; min-height: 48px; }
.timer-caption { color: #b2d3b0; font-size: 9px; font-weight: 900; letter-spacing: .8px; margin-right: 9px; white-space: nowrap; }
.timer-value { color: #e6f5cb; font-weight: 850; font-size: 27px; line-height: 35px; font-variant-numeric: tabular-nums; margin-right: auto; }
.timer-button { font-weight: 900; font-size: 10px; min-height: 36px; border-radius: 8px; padding: 0 12px; background: #c5eb8d; color: #192517; margin-left: 7px; }
.timer-reset { color: #d8e3db; background: #3b514e; border: 1px solid #61736d; }
.turn-timer.timer-low { background: #483b2a; border-color: #bc985d; }
.timer-low .timer-value, .timer-low .timer-caption { color: #ffd98e; }
.turn-timer.timer-expired { background: #492e32; border-color: #aa6460; }
.timer-expired .timer-value, .timer-expired .timer-caption { color: #ffb0aa; }
.timer-expired .timer-button:not(.timer-reset) { background: #6f484a; color: #ffc8c2; }
@media (max-width: 840px) {
  .timer-caption { font-size: 8px; margin-right: 5px; }
  .timer-value { font-size: 23px; }
  .timer-button { padding: 0 8px; font-size: 9px; margin-left: 4px; }
}
@media (max-width: 360px) {
  .timer-caption { display: none; }
}

/* Mordi v0.3: tabletop orientation. Rotate content only, keeping the card's
   position, dimensions and active border consistent. Prefixed for iOS 9. */
.player-inner { width: 100%; }
.player-card.is-flipped .player-inner {
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
  -webkit-transform-origin: 50% 50%;
  transform-origin: 50% 50%;
}
.layout-toggle {
  margin-right: 9px;
  border-color: #688453;
  color: #d4eeb8;
  font-size: 10px;
  padding-left: 10px;
  padding-right: 10px;
}
.layout-toggle[aria-pressed="false"] { color: #b5c2c9; border-color: #43515c; }
@media (max-width: 840px) {
  .layout-toggle { margin-right: 5px; font-size: 9px; padding: 8px; }
}
@media (max-width: 600px) {
  .layout-toggle { font-size: 9px; min-height: 44px; }
}

/* Mordi v0.4: iOS 9-safe, mathematically centered life button labels. */
.life-btn { position: relative; padding: 0; text-align: center; line-height: normal; }
.life-btn-label { position: absolute; left: 50%; top: 50%; display: block;
  min-width: 28px; white-space: nowrap; text-align: center; line-height: 1;
  -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
/* The score summary communicates progress toward 21, not just the maximum. */
.commander-summary-warn strong { color: #f4d28e; }
.commander-summary-lethal strong { color: #ffb2a9; }
/* Lightweight commander damage tracker: no gradients, grid, or new CSS APIs. */
.cmd-source { border: 1px solid #364653; background: #202b35; border-radius: 13px;
  padding: 10px; margin-top: 10px; }
.cmd-source-header { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  margin: 0 0 7px; min-height: 30px; }
.cmd-source-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  -webkit-flex: none; flex: none; margin-right: 8px; }
.cmd-source-name { -webkit-flex: 1; flex: 1; font-size: 14px; font-weight: 850;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-add-partner { min-height: 35px; background: #32444b; border: 1px solid #53675f;
  color: #d4edc1; border-radius: 8px; padding: 4px 9px; font-size: 10px; font-weight: 800; margin-left: 6px; }
.cmd-two-tracked { margin-left: 6px; font-size: 9px; color: #9eaeb0; font-weight: 800; }
.cmd-row { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  min-height: 59px; padding: 5px 0; border-top: 1px solid #3a4954; }
.cmd-info { -webkit-flex: 1; flex: 1; min-width: 52px; margin-right: 9px; }
.cmd-title { font-size: 11px; color: #dbe6e8; font-weight: 850; }
.cmd-progress { overflow: hidden; height: 7px; margin-top: 6px; margin-bottom: 6px;
  border-radius: 6px; background: #3b4a52; }
.cmd-progress-fill { display: block; height: 100%; background: #88bd91; border-radius: 6px; }
.cmd-warning .cmd-progress-fill { background: #e2b466; }
.cmd-lethal .cmd-progress-fill { background: #e9877e; }
.cmd-sub { font-size: 9px; font-weight: 800; color: #8da9ad; letter-spacing: .3px; }
.cmd-warning .cmd-sub { color: #eed19a; }
.cmd-lethal .cmd-sub { color: #ffb2a9; }
.cmd-value { white-space: nowrap; text-align: center; width: 70px; -webkit-flex: none; flex: none; }
.cmd-value strong { font-size: 24px; font-weight: 850; color: #eef3e9; font-variant-numeric: tabular-nums; }
.cmd-value span { color: #9aaab0; font-size: 12px; margin-left: 1px; }
.cmd-warning .cmd-value strong { color: #f4d28e; }
.cmd-lethal .cmd-value strong { color: #ffb2a9; }
.cmd-controls { display: -webkit-flex; display: flex; -webkit-flex: none; flex: none; }
.cmd-controls button { width: 40px; height: 44px; min-height: 44px; border-radius: 8px;
  margin-left: 4px; background: #3a4b57; color: #f0f3f1; font-size: 15px; font-weight: 850; padding: 0; }
.cmd-controls button:active { background: #596b77; }
@media (max-width: 600px) {
  .cmd-row { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .cmd-info { min-width: 110px; }
  .cmd-controls { width: 100%; -webkit-justify-content: flex-end; justify-content: flex-end; margin-top: 8px; }
  .cmd-value { width: 58px; }
}

/* Extra breathing room for the shorter Random First label on older Safari. */
.tool-buttons .btn { font-size: 11px; letter-spacing: .25px; padding-left: 7px; padding-right: 7px; }

/* Mordi v0.4.1: center toolbar labels by their actual rendered box,
   not the old Safari button text baseline. CSS table cells are supported
   by iOS 9 Safari and preserve each button's intrinsic width. */
.nav-centered { height: 44px; min-height: 44px; padding-top: 0; padding-bottom: 0;
  text-align: center; line-height: normal; }
.nav-centered .nav-table { display: table; height: 100%; margin: 0 auto; }
.nav-centered .nav-cell { display: table-cell; vertical-align: middle;
  height: 100%; line-height: 1; white-space: nowrap; }
.nav-centered .nav-icon { display: inline-block; margin-right: 6px;
  line-height: 1; vertical-align: baseline; font-size: 14px; }
.nav-centered .nav-arrow { display: inline-block; margin-left: 7px;
  line-height: 1; vertical-align: baseline; font-size: 17px; }
/* Replaces v0.1's larger NEXT TURN arrow spacing. */
.next-turn .nav-arrow { margin-left: 7px; }
@media (max-width: 600px) {
  .nav-centered { padding-left: 10px; padding-right: 10px; }
  .next-turn.nav-centered { padding-left: 9px; padding-right: 9px; }
  .nav-centered .nav-icon { margin-right: 0; }
  .nav-centered .wide-label { display: none; }
}
